produce reports by using the DATA step instead of using a procedure
direct data to an output file by using a FILE statement
Prerequisites
Before proceeding with this section, you should be familiar with the concepts presented
in the following sections:
Chapter 1, “What is the SAS System?,” on page 3
Chapter 3, “Introduction to DATA Step Processing,” on page 27
Understanding the PUT Statement
When you create output using the DATA step, you can customize that output by using
the PUT statement to write text to the SAS log or to another output file. The PUT
statement has the following form:
PUT<variable<format>> <'character-string'>;
variable
names the variable that you want to write.
format
specifies a format to use when you write variable values.
'character-string'
specifies a string of text to write. Be sure to enclose the string in quotation marks.
Writing Output without Creating a Data Set
In many cases, when you use a DATA step to write a report, you do not need to create an
additional data set. When you use the DATA _NULL_ statement, SAS processes the
DATA step without writing observations to a data set. Using the DATA _NULL_
statement can increase program efficiency considerably.
The following is an example of a DATA _NULL_ statement:
data _null_;
The following program uses a PUT statement to write women’s Olympic medalist
information to the SAS log. Because the program uses a DATA _NULL_ statement, SAS
does not create a data set.
data _null_;
length medalist $ 19;
input year 1-4 medalist $ 6-24 medal $ 26-31 country $ 33-35 result 37-41;
put medalist country medal result year;
datalines;
1984 Lingjuan Li SILVER CHN 2559
1984 Jin-Ho Kim BRONZE KOR 2555
1988 Soo-Nyung Kim GOLD KOR 2683
596 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.