Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It is vitally important to carefully inspect the SAS Log, especially when creating a SAS data set for the first time. A log filled with messages about invalid data values is a clue that something may be wrong, either with the data or the program. If you know that a numeric field contains invalid character values, you may choose to read those data values with a character informat and to perform a character-to-numeric conversion (using the INPUT function) yourself. This will keep the SAS Log cleaner and make it easier to spot unexpected errors. Let’s look at portions of the SAS Log that were generated when the PATIENTS data set was created.
1 LIBNAME CLEAN "C:\CLEANING";
NOTE: Libref CLEAN was successfully assigned as follows:
Engine: V7
Physical Name: C:\CLEANING
2
3 DATA CLEAN.PATIENTS;
4 INFILE "C:\CLEANING\PATIENTS.TXT" PAD;
5 INPUT @1 PATNO $3.
6 @4 GENDER $1.
7 @5 VISIT MMDDYY10.
8 @15 HR 3.
9 @18 SBP 3.
10 @21 DBP 3.
11 @24 DX $3.
12 @27 AE $1.;
13
14 LABEL PATNO = "Patient Number"
15 GENDER = "Gender"
16 VISIT = "Visit Date"
17 HR = "Heart Rate"
18 SBP = "Systolic Blood Pressure"
19 DBP = "Diastolic Blood Pressure"
20 DX = "Diagnosis Code"
21 AE = "Adverse Event?";
22
23 FORMAT VISIT MMDDYY10.;
24
25 RUN;
NOTE: The infile "C:\CLEANING\PATIENTS.TXT" is:
File Name=C:\CLEANING\PATIENTS.TXT,
RECFM=V,LRECL=256
NOTE: Invalid data for VISIT in line 7 5-14.
RULE: ---+---1---+---2---+---3---+---4---+---5---+---6---+---7---+---8
7 007M08/32/1998 88148102 0
RULE: ---+---1---+---2---+---3---+---4---+---5---+---6---+---7---+---8
92
183
PATNO=007 GENDER=M VISIT=. HR=88 SBP=148 DBP=102 DX= AE=0 _ERROR_=1 _N_=7
NOTE: Invalid data for VISIT in line 12 5-14.
12 011M13/13/1998 68300 20 41
92
183
PATNO=011 GENDER=M VISIT=. HR=68 SBP=300 DBP=20 DX=4 AE=1 _ERROR_=1 _N_=12
NOTE: Invalid data for VISIT in line 21 5-14.
21 123M15/12/1999 60 10
92
183
PATNO=123 GENDER=M VISIT=. HR=60 SBP=. DBP=. DX=1 AE=0 _ERROR_=1 _N_=21
NOTE: Invalid data for VISIT in line 23 5-14.
23 020F99/99/9999 10 20 8 0
92
183
PATNO=020 GENDER=F VISIT=. HR=10 SBP=20 DBP=8 DX= AE=0 _ERROR_=1 _N_=23
NOTE: Invalid data for VISIT in line 28 5-14.
NOTE: Invalid data for HR in line 28 15-17.
28 027FNOTAVAIL NA 166106 70
92
183
PATNO=027 GENDER=F VISIT=. HR=. SBP=166 DBP=106 DX=7 AE=0 _ERROR_=1 _N_=28
NOTE: 31 records were read from the infile "C:\CLEANING\PATIENTS.TXT".
The minimum record length was 26.
The maximum record length was 27.
NOTE: The data set CLEAN.PATIENTS has 31 observations and 8 variables.
NOTE: DATA statement used:
real time 0.50 seconds