Chapter 32
Writing Lines to the SAS Log or to
an Output File
Introduction to Writing Lines to the SAS Log or to an Output File . . . . . . . . . . . 595
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Understanding the PUT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Writing Output without Creating a Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Writing Simple Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Writing a Character String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Writing Variable Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Writing on the Same Line More Than Once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
Releasing a Held Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Writing a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Writing to an Output File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Designing the Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
Writing Data Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
Improving the Appearance of Numeric Data Values . . . . . . . . . . . . . . . . . . . . . . . 605
Writing a Value at the Beginning of Each BY Group . . . . . . . . . . . . . . . . . . . . . . . 606
Calculating Totals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Writing Headings and Footnotes for a One-Page Report . . . . . . . . . . . . . . . . . . . . 608
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
Learning More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
Introduction to Writing Lines to the SAS Log or to
an Output File
Purpose
In previous sections you learned how to store data values in a SAS data set and to use
SAS procedures to produce a report that is based on these data values. In this section,
you will learn how to do the following:
design output by positioning data values and character strings in an output file
prevent SAS from creating a data set by using the DATA _NULL_ statement
595

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.