/* Diagnosing errors from the SAS log --- Many people ignore the SAS log unless they see the red print that indicates an error. Some errors do not generate red print, since SAS is unable to tell whether you meant to do what you have told it to do or not. The following DATA step illustrates the most common SAS error and how this may show up in the log. */ data test; input x y z datalines; 9 3 2 8 4 4 7 3 2 9 2 6 4 8 2 ; run; /* Note that the log does not say "Missing semicolon" or anything even remotely like that. For all SAS knows, you have a variable named "datalines" in your data, and that is how it interprets your INPUT statement. */ /* The following example shows what happens when you forget to use a period to indicate a missing value. When using free form input, you should use . to represent a missing data point. */ data test; input x y z; datalines; 9 3 2 8 4 7 3 2 9 2 6 4 8 2 ; run; proc print; title "Missing data with no ."; run; /* Note that there is no red print at all. As far as SAS in concerned, there is no error. When SAS tries to read a value for "z" in the second line, it finds nothing there and goes to the beginning of the next line and reads a "7" for "z". It then loops back to the beginning of the DATA step and goes to the next line to read a value for "x". This is why the log indicates there are only 4 observations when there should be 5. Also note that the output is left-justified because of the OPTIONS statement we ran in the previous SAS program. Plus there is no date and time printed on the output for the same reason. */ options center date; /* The following example illustrates what happens when SAS encounters a character value when it is expecting a numeric value. */ data test; input x y z; datalines; 9 3 2 8 4 q 7 3 2 9 2 6 4 8 2 ; run; proc print; title "Character value instead of numeric"; run; /* Note once again that there is no red print in the SAS log. However, it does show that SAS considers this an error because it has set its automatic binary variable _ERROR_ to 1. Note also that there is another automatic variable printed here called _N_ that counts the number of times through the DATA step. This says that the error occurred on the second time through the DATA step. */ /* The next example shows what happens when there is missing data not represented by a . but it is the very last value in the data. */ data test; input x y z; datalines; 9 3 2 8 4 4 7 3 2 9 2 6 4 8 ; run; proc print; title "Lost card error"; run; /* This results in a LOST CARD note which SAS also considers an error because it has incremented its error counter. If there are a lot of errors in the DATA step, SAS will stop printing them after 20 errors of the same type. The LOST CARD says that the INPUT statement indicates that there should be more data values to read, but SAS can find no more. There are also only 4 observations in the data set instead of 5, since SAS could not finish reading the last observation. It was never able to write the last one to the data set. You will also get this LOST CARD message if you have a blank line at the end of your data (when reading data from an external file and not including the data within the program). */