Analyzing Your SAS Session with the SAS Log |
Using SAS System Options to Suppress Log Output |
There might be times when you want to prevent some information from being written to the SAS log. You can suppress SAS statements, system messages, and error messages with the NOSOURCE, NONOTES, and ERRORS= SAS system options. You can specify these options when you invoke SAS, in the OPTIONS window, or in an OPTIONS statement. In this section, the options are specified in OPTIONS statements.
Note that all SAS system options remain in effect for the duration of your session or until you change them.
Suppressing SAS Statements |
If you regularly execute large SAS programs without making changes, then you can use the NOSOURCE system option as follows to suppress the listing of the SAS statements to the log:
options nosource;
The NOSOURCE option causes only source lines that contain errors to be printed. You can return to the default by specifying the SOURCE system option as follows:
options source;
The SOURCE option causes all subsequent source lines to be printed.
You can also control whether secondary source statements (from files that are included with a %INCLUDE statement) are printed on the SAS log. Specify the following statement to suppress secondary statements:
options nosource2;
The following OPTIONS statement causes secondary source statements to print to the log:
options source2;
Suppressing System Notes |
Much of the information that is supplied by the log appears as notes, including
SAS also issues a note to tell you that it has stopped processing a step because of errors.
If you do not want the notes to appear on the log, then use the NONOTES system option to suppress their printing:
options nonotes;
All messages starting with NOTE: are suppressed. You can return to the default by specifying the NOTES system option:
options notes;
Limiting the Number of Error Messages |
SAS prints messages for data input errors that appear in your SAS program; the default number is usually 20 but might vary from site to site. Use the ERRORS= system option to specify the maximum number of observations for which error messages are printed.
Note that this option limits only the error messages that are produced for incorrect data. This kind of error is caused primarily by trying to read character values for a variable that the INPUT statement defines as numeric.
If data errors are detected in more observations than the number you specify, then processing continues, but error messages do not print for the additional errors. For example, the following OPTIONS statement specifies printing for a maximum of five observations:
options errors=5;
However, as discussed in Suppressing SAS Statements, Notes, and Error Messages, it might be dangerous to suppress error messages.
Note: No option is available to eliminate warning messages.
Suppressing SAS Statements, Notes, and Error Messages |
The following SAS program reads the test score data as in the other examples in this section, but in this example the character symbol for the variable GENDER is omitted. Also, the data is not sorted before using a BY statement with PROC PRINT. At the same time, for efficiency, SAS statements, notes, and error messages are suppressed.
libname out 'your-data-library'; options nosource nonotes errors=0; data out.sats5; infile 'your-input-file'; input test $ gender year SATscore 25-27; run; proc print; by test; run;
This program does not generate output. The SAS log that appears is shown in the following output. Because the SAS system option ERRORS=0 is specified, the error limit is reached immediately, and the errors that result from trying to read GENDER as a numeric value are not printed. Also, specifying the NOSOURCE and NONOTES system options causes the log to contain no SAS statements that can be verified and no notes to explain what happened. The log does contain an error message that explains that OUT.SATS5 is not sorted in ascending sequence. This error is not caused by invalid input data, so the ERRORS=0 option has no effect on this error.
Suppressing Information to the SAS Log
NOTE: Libref OUT was successfully assigned as follows: Engine: V8 Physical Name: YOUR-DATA-LIBRARY 370 options nosource nonotes errors=0; ERROR: Limit set by ERRORS= option reached. Further errors of this type will not be printed. ERROR: Data set OUT.SAT_SCORES5 is not sorted in ascending sequence. The current by-group has test = Verbal and the next by-group has test = Math.
Note: The NOSOURCE, NONOTES, and ERRORS= system options are used to save space. They are most useful with an already-tested program, perhaps one that is run regularly. However, as demonstrated in this section, they are not always appropriate. During development of a new program, the error messages in the log might be essential for debugging, and should not be limited. Similarly, notes should not be suppressed because they can help you pinpoint problems with a program. They are especially important if you seek help in debugging your program from someone not already familiar with it. In short, you should not suppress any information in the log until you have already executed the program without errors.
The following partial output shows the results if the previous sample SAS code is reexecuted with the SOURCE, NOTES, and ERRORS= options.
412 options source notes errors=20; 413 414 data out.sat_scores5; 415 infile 'YOUR-DATA-FILE'; 416 input test $ gender year score @@; 417 run; NOTE: The infile 'YOUR-DATA-FILE' is: File Name=YOUR-DATA-FILE, Owner Name=userid,Group Name=dev, Access Permission=rw-r--r--, File Size (bytes)=1998 NOTE: Invalid data for gender in line 1 8-8. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7 1 Verbal m 1972 531 Verbal f 1972 529 36 test=Verbal gender=. year=1972 score=531 _ERROR_=1 _N_=1 NOTE: Invalid data for gender in line 1 27-27. test=Verbal gender=. year=1972 score=529 _ERROR_=1 _N_=2 NOTE: Invalid data for gender in line 2 8-8. 2 Verbal m 1973 523 Verbal f 1973 521 36 test=Verbal gender=. year=1973 score=523 _ERROR_=1 _N_=3 NOTE: Invalid data for gender in line 2 27-27. test=Verbal gender=. year=1973 score=521 _ERROR_=1 _N_=4 . . . NOTE: Invalid data for gender in line 10 8-8. 10 Verbal m 1981 508 Verbal f 1981 496 36 test=Verbal gender=. year=1981 score=508 _ERROR_=1 _N_=19 NOTE: Invalid data for gender in line 10 27-27. ERROR: Limit set by ERRORS= option reached. Further errors of this type will not be printed. test=Verbal gender=. year=1981 score=496 _ERROR_=1 _N_=20 NOTE: 54 records were read from the infile 'YOUR-DATA-FILE'. The minimum record length was 36. The maximum record length was 36. NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: The data set OUT.SAT_SCORES5 has 108 observations and 4 variables. 418 419 proc print; 420 by test; 421 run; ERROR: Data set OUT.SAT_SCORES5 is not sorted in ascending sequence. The current by-group has test = Verbal and the next by-group has test = Math. NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 55 observations read from the data set OUT.SAT_SCORES5.
Again, this program does not generate output, but this time the log is a more effective problem-solving tool. The log includes all the SAS statements from the program as well as many informative notes. Specifically, it includes enough messages about the invalid data for the variable GENDER that the problem can be spotted. With this information, the program can be modified and rerun successfully.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.