Basic Usage

Overview

ODS is used by all SAS software. However, you can explicitly use ODS with the following:
  • DOCUMENT Procedure
  • ODS Global Statements
  • Base SAS Reporting Procedures
  • TEMPLATE Procedure

The DOCUMENT Procedure

The combination of the ODS DOCUMENT statement and the DOCUMENT procedure enables you to store a report’s individual components, and then modify and replay the report. The ODS DOCUMENT statement stores the actual ODS objects that are created when you run a report. You can then use PROC DOCUMENT to rearrange, duplicate, or remove output from the results of a procedure or a data query without invoking the procedures from the original report. You can also use PROC DOCUMENT to do the following:
  • transform a report without rerunning an analysis or repeating a data query
  • modify the structure of output
  • display output to any ODS output format without executing the original procedure or DATA step
  • navigate the current directory and list entries
  • open and list ODS documents
  • manage output
  • store the ODS output objects in raw form
    Note: The output is kept in the original internal representation as a data component plus a table template.
The DOCUMENT destination has a graphical user interface (GUI), called the Documents window, for performing tasks. However, you can perform the same tasks with batch statement syntax using the DOCUMENT procedure.
For complete documentation on the DOCUMENT procedure, see The DOCUMENT Procedure in SAS Output Delivery System: User's Guide.

ODS Global Statements

ODS global statements provide greater flexibility to generate, customize, and reproduce SAS procedure and DATA step output. You can use ODS global statements to control different features of ODS. ODS statements can be used anywhere in your SAS program. Some ODS statements remain in effect until you explicitly change them. Other ODS statements are automatically cleared. For complete documentation on ODS global statements, see the chapter about ODS statements in the SAS Output Delivery System: User's Guide.
ODS global statements are organized into two types.
Output Control Statements
are statements that provide descriptive information about the specified output objects, and they indicate whether the style definition or table template is provided by SAS. The ODS EXCLUDE, ODS SELECT, and ODS TRACE statements are examples of output control statements.
Output control statements can do the following:
  • select specific output objects for specific destinations
  • exclude specific output objects from specific destinations
  • specify the location where you want to search for or store style definitions or table templates
  • verify whether you are using a style definition or a table template that is provided by SAS
  • provide descriptive information about each specified output object, such as its name, label, template, path, and label path
ODS Destination (Report) Statements
are statements that enable you to create output that is formatted for third-party software, such as HTML, RTF, and PDF. Or, they enable you to create output that is specific to SAS, such as an ODS document, LISTING output, or a SAS data set.
You can use ODS destination statements to generate and modify reports in formats such as HTML, XML, PDF, PostScript, RTF, and Microsoft Excel. The form for an ODS destination statement is the ODS statement block, which consists of ODS statements that open and close one or more ODS destinations sandwiched around your program. Your results are sent to one or more output destinations.
You can use one or more ODS destination statements, one or more PROC or DATA steps, and an ODS CLOSE statement to form an ODS statement block. An ODS block has the following form:
ODS output-destination 1 <options(s)>;
...
ODS output-destination (n) <options(s)>
<your SAS program>
ODS destination close statement 1;
...
ODS destination close statement (n)
In the ODS block, output-destination is the name of a valid ODS destination and option(s) are options that are valid for that destination. Your SAS program is inserted between the beginning ODS destination statement and the ODS CLOSE statement.
In the following example, the output from PROC PRINT and PROC CONTENTS is sent to the PDF and RTF destinations. The STYLE= option specifies what table template to apply to the output. By default, the PDF opens in Adobe Acrobat and the RTF opens in Microsoft Word.
options obs=10 nodate;
ods pdf file="myPdf.pdf" style=Banker;
ods rtf file="myRTF.rtf" style=BarrettsBlue text="RTF Output";
proc print data=sashelp.class;
run;

proc contents data=sashelp.class;
run;

ods pdf close;
ods rtf close;
Default PDF Output
Default PDF Output
PDF Output with Banker Style Applied
PDF Output with Banker Style Applied
Default RTF Output
Default RTF Output
RTF Output with BarrettsBlue Style Applied
RTF Output with BarrettsBlue Style Applied
ODS destinations are organized into two categories.
Destinations Formatted by SAS
These destinations produce output that is controlled and interpreted by SAS, such as a SAS data set, LISTING output, or an ODS document.
Destinations Formatted by a Third Party
These destinations produce output that enables you to apply styles or markup languages. You can print to physical printers using page description languages. For example, you can produce output in PostScript, HTML, XML, or in a markup language that you created.
The following table lists the ODS destination categories, the destinations that each category includes, and the formatted output that results from each destination.
Destination Category Table
Category
Destinations
Results
Formatted by SAS
DOCUMENT
ODS document
LISTING
SAS LISTING output
OUTPUT
SAS data set
Formatted by a Third Party
HTML
HTML file for online viewing
MARKUP
Markup language tagsets
PRINTER
Printable output in one of three different formats: PCL, PDF, or PS (PostScript)
RTF
Output written in Rich Text Format for use with Microsoft Word 2000
As destinations are added to ODS, they will automatically become available to the DATA step and all procedures that support ODS.

Base SAS Reporting Procedures

The Base SAS reporting procedures, PROC PRINT, PROC REPORT, and PROC TABULATE, enable you to quickly analyze your data and organize it into easy-to-read tables. You can use ODS options with the reporting procedures to give your report another dimension of expression and usability. For example, you can use the STYLE option with a PROC PRINT, PROC REPORT, or PROC TABULATE statement to change the appearance of your report. The following program uses the ODS STYLE option to create the colors in the output below:
Title "Height and Weight by Gender and Age";
proc report nowd data=sashelp.class
   style(header)=[background=white];
   col age (('gender' sex),(weight height));
   define age / style(header)=[background=lightgreen];
   define sex / across style(header)=[background=yellow] ' ';
   define weight / style(header)=[background=orange];
   define height / style(header)=[background=tan];
run;
PROC REPORT Output with Styles Applied
PROC REPORT Output with Styles Applied
For complete documentation on the styles and style attributes that you can use with PROC PRINT, PROC TABULATE, and PROC REPORT, see the Base SAS Procedures Guide.

TEMPLATE Procedure

All SAS procedures produce output objects that ODS delivers to various ODS destinations based on the default specifications for the procedure or based on your own specifications. Output objects are commonly displayed as tables, data sets, or graphs. Each output object has an associated template provided by SAS that defines its presentation format. You can use the TEMPLATE procedure to view or alter a template or to create a new template by changing the headers, formats, column order, and so on.
The TEMPLATE procedure enables you to create or modify a template that you can apply to your output. You can also use the TEMPLATE procedure to navigate and manage the templates stored in template stores. ODS then uses these templates to produce formatted output. Using the TEMPLATE procedure is an advanced technique. For more information about advanced ODS techniques, see Next Steps: A Quick Look at Advanced Features .
For complete documentation on the TEMPLATE procedure, see the TEMPLATE procedure in the SAS Output Delivery System: User's Guide.