Email address normalization in SAS

This SAS macro performs email address normalization by changing email addresses like First.Last+tag@googlemail.com to the canonical form firstlast@gmail.com. Also, it demonstrates basic unit testing in SAS, which ensures quality and eases code maintenance. Email address normalization is often used to transform email addresses into unique keys for identifying or preventing duplicate accounts

Phone number validation in SAS

In SAS it’s trivial to perform basic validation of a US phone number using a regular expression, and this SAS macro goes way behind the basic validation rules: it checks several rules, in service area codes, directory service, and special phone numbers. Simple unit testing ensures the macro works as intended.

Checking return codes for errors in SAS

You should check for error return codes in any SAS programs that run unattended in batch jobs, so you can handle the exception properly. For example, if the data are invalid, you don’t want to generate reports or insert bad data into a database. Also it can save time to abort as soon as the…

Avoid truncating characters in PROC IMPORT csv

Watch out for this common pitfall when importing .CSV files into SAS using the PROC IMPORT procedure. If your .CSV files always have character strings only with consistent widths (such as ISBN book codes, ethernet MAC addresses, UPC barcodes, Social Security Numbers) or numeric values only, then you may stop reading now. However, if your…

Validating credit card numbers in SAS

Major credit card issuing networks (including Visa, MasterCard, Discover, and American Express) allow simple credit card number validation using the Luhn Algorithm (also called the “modulus 10” or “mod 10” algorithm). The following code demonstrates an implementation in SAS. The code also validates the credit card number by length and by checking against a short…