Chapter 3
Using ODS with the DATA Step
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
How ODS Works with the DATA Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Syntax for ODS Enhanced Features in a DATA Step . . . . . . . . . . . . . . . . . . . . . . . . 53
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
PUT Statement for ODS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
FILE Statement for ODS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Example 1: Creating a Report with the DATA Step and the
Default Table Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Example 2: Producing ODS Output That Contains Selected Variables . . . . . . . . . . 71
Example 3: Assigning Attributes to Columns in ODS Output . . . . . . . . . . . . . . . . . 76
Example 4: Creating and Using a User-Defined Table Template . . . . . . . . . . . . . . 83
Introduction
If you are writing DATA step reports now, you are already using ODS. HTML output,
the DATA step output, is routed though ODS by default. For more than 20 years, SAS
users have been able to create highly customized reports as simple LISTING output,
which uses a monospace type font. With the advent of ODS, however, you have a broad
range of choices for printing your customized DATA step reports:
You can produce DATA step reports in many different formats, such as HTML,
RTF, PS (PostScript), or PDF.
You can create the report in multiple formats at the same time.
You can also produce the report in different formats at a later time without rerunning
the DATA step.
You can use the Report Writing Interface to create highly customized reports with
the DATA step.
To take advantage of these enhanced reporting capabilities, you can combine DATA step
programming with the formatting capabilities of ODS. To create PDF output, for
example, start with the DATA steps tools that you are already familiar with:
the DATA _NULL_ statement
the FILE statement
the PUT statement
51

Get SAS 9.4 Output Delivery System, 3rd 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.