Previous Page | Next Page

Writing Lines to the SAS Log or to an Output File

Review of SAS Tools


Statements

BY variable-1 <. . . variable-n > <NOTSORTED>;

indicates that all observations with common values of the BY variables are grouped together. The NOTSORTED option indicates that the variables are grouped but that the groups are not necessarily in alphabetical or numerical order.

DATA _NULL_;

specifies that SAS will not create an output data set.

FILE PRINT <NOTITLES> <FOOTNOTES>;

directs output to the SAS procedure output file. Place the FILE statement before the PUT statements that write to that file. The NOTITLES option suppresses titles that are currently in effect, and makes the lines unavailable for writing other text. The FOOTNOTES option, along with the FOOTNOTE statement, writes a footnote to the file.

PUT;

by default, begins a new line and releases a previously held line. A PUT statement that does not write any text is known as a null PUT statement.

PUT <variable <format>> <character string>;

writes lines to the destination that is specified in the FILE statement; if no FILE statement is present, then the PUT statement writes to the SAS log. By default, each PUT statement begins on a new line, writes what is specified, and releases the line. A DATA step can contain any number of PUT statements.

By default, SAS writes a variable or character-string at the current position in the line. SAS automatically moves the pointer one column to the right after writing a variable value but not after writing a character string; that is, SAS places a blank after a variable value but not after a character string. This form of output is called list output. If you place a format after a variable name, then SAS writes the value of the variable beginning at its current position in the line and using the format that you specify. The position of the pointer after a formatted value is the following column; that is, SAS does not automatically skip a column. Using a format in a PUT statement is called formatted output. You can combine list and formatted output in a single PUT statement.

PUT<@n> <variable <format>> <character-string> </> <@>;

writes lines to the destination that is specified in the FILE statement; if no FILE statement is present, then the PUT statement writes to the SAS log. The @n pointer control moves the pointer to column n in the current line. The / moves the pointer to the beginning of a new line. (You can use slashes anywhere in the PUT statement to skip lines.) Multiple slashes skip multiple lines. The trailing @, if present, must be the last item in the PUT statement. Executing a PUT statement with a trailing @ holds the current line for use by a later PUT statement either in the same iteration of the DATA step or a later iteration. Executing a PUT statement without a trailing @ releases a held line.

TITLE;

specifies title lines for SAS output.

Previous Page | Next Page | Top of Page