Checking for Invalid Dates

Some of the dates in the PATIENTS data set are missing and some are invalid dates, which were converted to missing values during the input process. If you want to distinguish between the two, you must work from the raw data, not the SAS data set. If you attempt to read an invalid date with a SAS date informat, an error message will appear in the SAS Log. This is one clue that you have errors in your date values. Program 4-3 reads the raw data file PATIENTS.TXT. The resulting SAS Log follows.

Program 4-3. Reading Dates with the MMDDYY10. Informat
DATA DATES;
   INFILE "C:\CLEANING\PATIENTS.TXT" PAD;
   INPUT @5 VISIT MMDDYY10.;
   FORMAT VISIT MMDDYY10.;
RUN;

The SAS Log that results from running this program is shown next. ...

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.