SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2

Structure of the Log

The SAS log is a record of everything you do in your SAS session or with your SAS program. Original program statements are identified by line numbers . Interspersed with SAS statements are messages from SAS. These messages may begin with the words NOTE, INFO , WARNING, ERROR, or an error number, and they may refer to a SAS statement by its line number in the log.

For example, in the following output, the number 1 prints to the left of the OPTIONS statement. This means that it is the first line in the program. In interactive mode, SAS continues with the sequence of line numbering until you end your session. If you submit the program again (or submit other programs in your current SAS session), the first program line number will be the next consecutive number.

Operating Environment Information: The SAS log appears differently depending on your operating environment. See the SAS documentation for your operating environment.

Output 10.1: Sample SAS Log

NOTE: Copyright (c) 2002--2003 by SAS Institute Inc., Cary, NC, USA. NOTE: SAS (r) 9.1 (TS1B0) Licensed to SAS Institute Inc., Site 0000000001. NOTE: This session is executing on the HP-UX B.10.20 platform. NOTE: SAS initialization used: real time 4.20 seconds cpu time 1.18 seconds 1 options pagesize=24 linesize=64 nodate; 2 3 data logsample; 4 infile '/u/abcdef/testdir/sampledata.dat'; 5 input LastName $ 1-12 ID $ Gender $ Birth : date7. 5 ! score1 score2 score3 6 score 6 ! 4 score5 score6; 7 format Birth mmddyy8.; 8 run; NOTE: The infile '/u/abcdef/testdir/sampledata.dat' is: File Name=/u/abcdef/testdir/sampledata.dat, Owner Name=abcdef,Group Name=pubs, Access Permission=rw-r--r--, File Size (bytes)=296 NOTE: 5 records were read from the infile '/u/abcdef/testdir/sampledata.dat'. The minimum record length was 58. The maximum record length was 59. NOTE: The data set WORK.LOGSAMPLE has 5 observations and 10 variables. NOTE: DATA statement used: real time 0.44 seconds cpu time 0.13 seconds 9 10 proc sort data=logsample; 11 by LastName; 12 NOTE: There were 5 observations read from the dataset WORK.LOGSAMPLE. NOTE: The data set WORK.LOGSAMPLE has 5 observations and 10 variables. NOTE: PROCEDURE SORT used: real time 0.16 seconds cpu time 0.03 seconds 13 proc print data=logsample; 14 by LastName; 15 run; NOTE: There were 5 observations read from the dataset WORK.LOGSAMPLE. NOTE: PROCEDURE PRINT used: real time 0.31 seconds cpu time 0.05 seconds

 

The following list corresponds to the circled numbers in the SAS log shown above:

‘ copyright information.

‘¢ SAS system release used to run this program.

‘ name and site number of the computer installation where the program ran.

‘ platform used to run the program.

‘ OPTIONS statement. This statement uses SAS system options to set a page size of 24 and a line size of 64, and to suppress the date in the output.

‘ SAS statements that make up the program (if the SAS system option SOURCE is enabled).

Ԥ long statement continued to the next line. Note that the continuation line is preceded by an exclamation point (!), and that the line number does not change.

‘ input file information-notes or warning messages about the raw data and where they were obtained (if the SAS system option NOTES is enabled).

‘ the number and record length of records read from the input file (if the SAS system option NOTES is enabled).

‘  SAS data set that your program created; notes that contain the number of observations and variables for each data set created (if the SAS system option NOTES is enabled).

‘ procedure that sorts your data set

‘¢ note about the sorted SAS data set

‘ procedure that prints your data set.

Writing to the Log

You can instruct SAS to write additional information to the log by using the following statements:

PUT statement

writes selected lines (including text strings and DATA step variable values) to the SAS log. This behavior of the PUT statement requires that your program does not execute a FILE statement before the PUT statement in the current iteration of a DATA step, and that it does not execute a FILE LOG; statement.

%PUT statement

enables you to write a text string or macro variable values to the SAS log. %PUT is a SAS macro program statement that is independent of the DATA step and can be used anywhere .

LIST statement

writes to the SAS log the input data records for the data line that is being processed . The LIST statement operates only on data that are read with an INPUT statement. It has no effect on data that are read with a SET, MERGE, MODIFY, or UPDATE statement. Use the LIST statement in a DATA step.

ERROR statement

sets the automatic _ERROR_ variable to 1 and optionally writes to the log a message that you specify. Use the ERROR statement in a DATA step.

Use the PUT, LIST, and ERROR statements in combination with conditional processing to debug DATA steps by writing selected information to the log.

Customizing the Log

Altering the Contents of the Log

When you have large SAS production programs or an application that you run on a regular basis without changes, you might want to suppress part of the log. SAS system options enable you to suppress SAS statements and system messages, as well as to limit the number of error messages. Note that all SAS system options remain in effect for the duration of your session or until you change the options. You should not suppress log messages until you have successfully executed the program without errors.

The following list describes some of the SAS system options that you can use to alter the contents of the log:

CPUID NOCPUID

controls whether hardware information is written to the SAS log.

ECHOAUTO NOECHOAUTO

controls whether autoexec code in an input file is written to the log.

ERRORS= n

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

MPRINT NOMPRINT

controls whether SAS statements that are generated by macro execution are written to the SAS log.

MSGLEVEL=N I

controls the level of detail in messages that are written to the SAS log. If the MSGLEVEL system option is set to N, the log displays notes, warnings, and error messages only. If MSGLEVEL is set to I, the log displays additional notes pertaining to index usage, merge processing, and sort utilities, along with standard notes, warnings, and error messages.

NEWS= external-file

controls whether news information that is maintained at your site is written to the SAS log.

NOTES NONOTES

controls whether notes (messages beginning with NOTE) are written to the SAS log. NONOTES does not suppress error or warning messages.

OVP NOOVP

controls whether output lines that are printed by SAS are overprinted.

PRINTMSGLIST NOPRINTMSGLIST

controls whether extended lists of messages are written to the SAS log.

SOURCE NOSOURCE

controls whether SAS writes source statements to the SAS log.

SOURCE2 NOSOURCE2

controls whether SAS writes secondary source statements from files included by %INCLUDE statements to the SAS log.

SYMBOLGEN NOSYMBOLGEN

controls whether the results of resolving macro variable references are written to the SAS log.

See SAS Language Reference: Dictionary for more information about how to use these and other SAS system options.

Operating Environment Information: See the documentation for your operating environment for other options that affect log output.

Customizing the Appearance of the Log

The following SAS statements and SAS system options enable you to customize the log. Customizing the log is helpful when you use the log for report writing or for creating a permanent record.

DATE system option

controls whether the date and time that the SAS job began are printed at the top of each page of the SAS log and any output created by SAS.

FILE statement

enables you to write the results of PUT statements to an external file. You can use the following two options in the FILE statement to customize the log for that report.

LINESIZE= value

 

specifies the maximum number of columns per line for reports and the maximum record length for data files.

PAGESIZE= value

 

specifies the maximum number of lines to print on each page of output.

 
Note  

FILE statement options apply only to the output specified in the FILE statement, whereas the LINESIZE= and PAGESIZE= SAS system options apply to all subsequent listings.

LINESIZE= system option

specifies the line size (printer line width) for the SAS log and SAS output that are used by the DATA step and procedures.

MISSING= system option

specifies the character to be printed for missing numeric variable values.

NUMBER system option

controls whether the page number prints on the first title line of each page of printed output.

PAGE statement

skips to a new page in the SAS log and continues printing from there.

PAGESIZE= system option

specifies the number of lines that you can print per page of SAS output.

SKIP statement

skips a specified number of lines in the SAS log.

Operating Environment Information: The range of values for the FILE statement and for SAS system options depends on your operating environment. See the SAS documentation for your operating environment for more information.

For more information about how to use these and other SAS system options and statements, see SAS Language Reference: Dictionary .

Категории