Using the ERROR Statement to Identify a Data Error
I haven’t tried this yet, but it looks wicked. You can write custom error messages to help you debug your programs.
Let’s say during your datastep, you have an If Statement:
if daysout lt 0 then do;
error ‘Days checked out less than zero: ‘ itemid=
checkout= daysout=;
end;
The SAS Log will look like:
17 if daysout lt 0 then do;
18 error ‘Days checked out less than zero: ‘ itemid=
19 checkout= daysout=;
20 end;
21 run;
Days checked out less than zero: itemid=LIB0397
checkout=05/14/2001 daysout=-31
itemid=LIB0397 checkout=05/14/2001 duedate=06/14/2001
empno=001005 canrenew=Y nrenew=0
NOTE: There were 446 observations read from the dataset CORPLIB.CIRCUL.
NOTE: The data set WORK.USAGE has 446 observations and 9 variables.
NOTE: DATA statement used: real time 0.22 seconds


Reader Comments