Extending the Validation Macro to Include Valid Character Ranges

Besides listing discrete character values for each of the character variables to be tested, you might want to indicate a range of possible values such as ‘A’ to ‘E’. The macro that follows does just that. It allows the user to include discrete character values as well as ranges in the validation data set. For example, to check for the values ‘A’, ‘B’, ‘AB’, ‘C’, ‘DDD’ to ‘FFF’, and ‘X’ to ‘Z’, for a variable called CODE, you would enter the line:

CODE A B AB C DDD-FFF X-Z   Y

The program needs to search the string (VALUES_LIST) for dashes and treat the strings directly before and directly after it, as the beginning and ending values for a range. Luckily for us, SAS has a good selection ...

Get Cody’s Data Cleaning Techniques Using SAS® Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.