ODS and the DATA Step

If you are writing DATA step reports, you are already using ODS. HTML output, which is the DATA step output, is routed through 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, SAS users have a broad range of choices for printing 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 produce the report in different formats at a later time without rerunning 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 step tools that you are already familiar with.
  • the DATA _NULL_ statement
  • the FILE statement
  • the PUT statement
Then, add a few simple ODS statements and options. You can choose from several ODS formatting statements to format the output in other presentation styles, such as HTML, RTF, and PS. For more information about ODS statements, see the Introduction to ODS Language Statements in SAS Output Delivery System: User's Guide.
Here are the basic steps for using ODS with the DATA step to produce reports with enhanced formatting:
Steps to Produce Enhanced ODS Output with the DATA Step
Steps
Tools
Comments
Specify formatting for your output.
ODS formatting statements can specify formats such as listing, HTML, RTF, PS, and PDF.
You can produce output in multiple formats at the same time by specifying more than one format.
Note: If you want only the default output, then you do not need a destination ODS statement.
Specify structure.
The ODS option in the FILE statement lists the variables and the order in which they appear in the output.
Additional suboptions give you even more control over the structure.
Connect the data to the template.
The FILE PRINT ODS statement creates an output object by binding a data component to a table definition (template).
You can specify other details by using ODS suboptions in the FILE PRINT ODS statement.
Output data.
The PUT statement writes variable values to the data component.
A simple way to output all variable values is to use PUT _ODS_.
Use ODS statements to specify how you want ODS to format your output (for example, as HTML, RTF, or PDF). Then, in the DATA step, use the FILE PRINT ODS and PUT statements with appropriate ODS-specific suboptions to produce your report.
The PUT statement writes variable values. The FILE PRINT ODS statement directs the output.(footnote1) You can use ODS to produce the output in multiple formats and to produce output at a later time in different formats without rerunning the DATA step.
You control the formatting that is applied to your reports using ODS formatting statements. They open and close ODS destinations, which apply formatting to the output objects that you create with ODS and the DATA step.
Here is a list of topics and sources for additional information:
Where to Find More Information about How to Use ODS in the DATA Step
Topic
Where to learn more
ODS formatting statements
Dictionary of ODS Language Statements in SAS Output Delivery System: User's Guide
ODS destinations
Understanding ODS Destinations in SAS Output Delivery System: User's Guide
How ODS works
Overview of How ODS Works in SAS Output Delivery System: User's Guide
FOOTNOTE 1:If you do not specify a FILE statement, then the PUT statement writes to the SAS log, by default. If you use multiple PUT and FILE statements, then in addition to creating ODS-enhanced output, you can write to the SAS log, to the regular DATA step output buffer, or to another external file in the same DATA step.[return]