Suppressing Error Messages - SAS Programming

There may be situations when your numeric data will intentionally contain character values,such as the characters NA,meaning "Not Applicable", or other meaningful abbreviations.Although this will have meaning toyou,the SAS System will complain about seeing these "invalid" character strings when it is expecting only pure numeric data.

When this happens,the SAS log will ordinarily notify you that it has encountered invalid data.If this occurs often enough as a SAS data set is being built,the system log will eventually stop issuing the error messages and notify you that it has stopped,its error message limit having been exceeded. Here is a short program with some invalid data and the accompanying SAS log:

Example

DATA ERRORS;
INPUT X 1-2
Y 4-5;
DATALINES;
11 23
23 NA
NA 47
55 66
;

Here is the SAS log:

1 DATA ERRORS;
2 INPUT X 1-2
3 Y 4-5;
4 DATALINES;
NOTE: Invalid data for Y in line 5 4-5.
RULE: + 1 + 2 + 3 + 4 + 5-
5 23 NA
X=23 Y=. _ERROR_=1 _N_=2
NOTE: Invalid data for X in line 7 1-2.
7 NA 47
X=. Y=47 _ERROR_=1 _N_=3
NOTE: The data set WORK.ERRORS has 4 observations and 2
variables.
NOTE: The DATA statement used 0.06 CPU seconds and 2385K.
9 ;

When the system encounters an invalid value for a variable,it does a number of things:first, it informs you of its discovery and displays the offensive value.Next it assigns a missing value,.,to the offending variable for the current observation.If you know beforehand that your raw data contain values that the system will consider invalid, such as NA for a numeric variable, you may want to avoid the possibly numerous pages of SAS System error messages.You have two choices:

  1. You can save paper by placing a single question mark (?) following a variable name to instruct the system to suppress this type of error message while continuing to print the offending line of data to the log.
  2. You can save even more paper by using a double question mark (??) to suppress the printing of all error messages as well as the offending data lines.Here is the example with double ??'s being used,along with the resulting SAS log.

The program:

Example

DATA ERRORS?
INPUT X ?? 1-2
Y ?? 4-5;
DATAIJNES?
11 23
23 NA
lift. 47
55 66
••
J

And the SAS log:

1 DATA ERRORS;
2 INPUT X ?? 1-2
3 Y ?? 4-5;
4 DATALINES;
NOTE: The data set WORK.ERRORS has 4 observations and 2
variables.
NOTE: The DATA statement used 0.05 CPU seconds and 2361K.
9 ;

It goes without saying (but as is our wont, we'll say it anyway),that the single and double question marks should be used with caution.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAS Programming Topics