• produce reports by using the DATA step instead of using a procedure
• direct data to an output file by using a FILE statement
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:
names the variable that you want to write.
specifies a format to use when you write variable values.
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:
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.
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;
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