Use SAS system options to suppress Log output

For Windows SAS system, the Output, Log, and Program Editor windows can display approximately 99,999 lines each. Since the number is limited, sometimes the SAS Log windows will be full and the system will show a messages ‘SAS log window is full’. The running program will pause and wait for your action. It’s quite annoying, especially when you run a program with hundreds or thousands of loops.

I run a simulation program with a loop that went 100,000 times recently and it took more than 4 hours to run, even on the sever. And I want to suppress the log output because I don’t want that message to interrupt the program running.

I read the SAS documents carefully, and there are several option available to prevent the log window from filling up.

Solution 1: System options

There are four system options can be used to suppress SAS statements, system messages, and error message, respectively.

Errors – specifies the maximum number of observations for which data error messages are printed.

Notes – controls whether messages beginning with NOTE are written to the SAS log. Because notes are required for debugging, use this option until your program is error free.

Source – controls whether SAS program source statements are written to the SAS log.

Source2 – controls whether secondary source statements and notes about secondary source statements from files included by %INCLUDE statements are written to the SAS log.

Use the NOSOURCE system option to suppress the listing of the SAS statements to the log:

options nosource;

Use the NOSOURCE2 to suppress secondary statements (from files that are included with a %INCLUDE statement).

options nosource2;

Use the NONOTES system option to suppress the notes (including copyright, licensing, site information and number of observations and variables in the data set):

options nonotes;

No option is available to eliminate warning messages. Use the ERRORS= system option to specify the maximum number of observations for which error messages are printed.

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;

All in all, add the following OPTIONS statement to the top of your SAS program and you can suppress all kinds of log outputs:

options nonotes nosource nosource2 errors=0;

 

Solution 2: Redirect the log output to a file instead of the Log window.

To accomplish this, you can run a SAS program under the batch mode and it will automatically output the log to a file. Also, you can always explicitly ask SAS to do this, just adding the following code to the top of your program:

proc printto log="c:directory-namefilename.log"; 
run;

Or, if you don’t want to save the contents of the log at all, use the Microsoft Windows NUL device:

proc printto log="nul:"; 
run;

Then, at the end of your program, add the following code to redirect the output back to the Log window:

proc printto; 
run;

 

Reference: 

http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001906177.htm

http://support.sas.com/kb/5/888.html

Posted in SAS Programming Tips and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *