Notice that a blank line appears between the last line of the heading and the first data for
Massachusetts, although the PUT statement for the heading does not write a blank line.
The line comes from the slash (/) in the PUT statement that writes the value of STATE in
the first observation of each BY group.
Executing a PUT statement during the first iteration of the DATA step is a simple way to
produce headings, especially when a report is only one page long.
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.
specifies that SAS will not create an output data set.
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
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. SAS also uses 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
610 Chapter 32 Writing Lines to the SAS Log or to an Output File

Get Step-by-Step Programming with Base SAS 9.4, Second Edition, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.