SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2

What Is the Output Delivery System?

The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure and DATA step output, with a wide range of formatting options. ODS provides formatting functionality that is not available from individual procedures or from the DATA step alone. ODS overcomes these limitations and enables you to format your output more easily.

Prior to Version 7, most SAS procedures generated output that was designed for a traditional line-printer. This type of output has limitations that prevents you from getting the most value from your results:

Gallery of ODS Samples

Introduction to the ODS Samples

This section shows you samples of the different kinds of formatted output that you can produce with ODS. The input file contains sales records for TruBlend Coffee Makers, a company that distributes coffee machines.

Listing Output

Traditional SAS output is Listing output. You do not need to change your SAS programs to create listing output. By default, you continue to create this kind of output even if you also create a type of output that contains more formatting.

Output 10.2: Listing Output

Average Quarterly Sales Amount by Each Sales Representative 1 --------------------------------- Quarter=1 --------------------------------- The MEANS Procedure Analysis Variable : AmountSold N SalesRep Obs N Mean Std Dev Minimum Maximum _____________________________________________________________________________ Garcia 8 8 14752.5 22806.1 495.0 63333.7 Hollingsworth 5 5 11926.9 12165.2 774.3 31899.1 Jensen 5 5 10015.7 8009.5 3406.7 20904.8 _____________________________________________________________________________ Average Quarterly Sales Amount by Each Sales Representative 2 --------------------------------- Quarter=2 ---------------------------------- The MEANS Procedure Analysis Variable : AmountSold N SalesRep Obs N Mean Std Dev Minimum Maximum _____________________________________________________________________________ Garcia 6 6 18143.3 20439.6 1238.8 53113.6 Hollingsworth 6 6 16026.8 14355.0 1237.5 34686.4 Jensen 6 6 12455.1 12713.7 1393.7 34376.7 _____________________________________________________________________________ Average Quarterly Sales Amount by Each Sales Representative 3 --------------------------------- Quarter=3 --------------------------------- The MEANS Procedure Analysis Variable : AmountSold N SalesRep Obs N Mean Std Dev Minimum Maximum _____________________________________________________________________________ Garcia 21 21 10729.8 11457.0 2787.3 38712.5 Hollingsworth 15 15 7313.6 7280.4 1485.0 30970.0 Jensen 21 21 10585.3 7361.7 2227.5 27129.7 _____________________________________________________________________________ Average Quarterly Sales Amount by Each Sales Representative 4 --------------------------------- Quarter=4 --------------------------------- The MEANS Procedure Analysis Variable : AmountSold N SalesRep Obs N Mean Std Dev Minimum Maximum _____________________________________________________________________________ Garcia 5 5 11973.0 10971.8 3716.4 30970.0 Hollingsworth 6 6 13624.4 12624.6 5419.8 38093.1 Jensen 6 6 19010.4 15441.0 1703.4 38836.4 _____________________________________________________________________________

 

PostScript Output

With ODS, you can produce output in PostScript format.

Display 10.1: PostScript Output Viewed with Ghostview

HTML Output

With ODS, you can produce output in HTML (Hypertext Markup Language.) You can browse these files with Internet Explorer, Netscape, or any other browser that fully supports the HTML 3.2 tagset.

Note  

To create HTML 4.0 tagsets, use the ODS HTML4 statement. In SAS 9, the ODS HTML statement generates HTML 3.2 tagsets. In future releases of SAS, the ODS HTML statement will support the most current HTML tagsets available.

Display 10.2: HTML Output Viewed with Microsoft Internet Explorer

RTF Output

With ODS, you can produce RTF (Rich Text Format) output which is used with Microsoft Word.

Display 10.3: RTF Output Viewed with Microsoft Word

PDF Output

With ODS, you can produce output in PDF (Portable Document Format), which can be viewed with the Adobe Acrobat Reader.

Display 10.4: PDF Output Viewed with Adobe Acrobat Reader

XML Output

With ODS, you can produce output that is tagged with XML (Extensible Markup Language) tags.

Output 10.3: XML Output file

<?xml version="1.0" encoding="windows-1252"?> <odsxml> <head> <meta operator="user"/> </head> <body> <proc name="Print"> <label name="IDX"/> <title class="SystemTitle" toc-level="1">US Census of Population and Housing</title> <branch name="Print" label="The Print Procedure" class="ContentProcName" toc-level="1"> <leaf name="Print" label="Data Set SASHELP.CLASS" class="ContentItem" toc-level="2"> <output name="Print" label="Data Set SASHELP.CLASS" clabel="Data Set SASHELP.CLASS"> <output-object type="table" class="Table"> <style> <border spacing="1" padding="7" rules="groups" frame="box"/> </style> <colspecs columns="6"> <colgroup> <colspec name="1" width="2" align="right" type="int"/> </colgroup> <colgroup> <colspec name="2" width="7" type="string"/> <colspec name="3" width="1" type="string"/> <colspec name="4" width="2" align="decimal" type="double"/> <colspec name="5" width="4" align="decimal" type="double"/> <colspec name="6" width="5" align="decimal" type="double"/> </colgroup> </colspecs> <output-head> <row> <header type="string" class="Header" row="1" column="1"> <value>Obs</value> </header> <header type="string" class="Header" row="1" column="2"> <value>Name</value> </header> <header type="string" class="Header" row="1" column="3"> <value>Sex</value> </header> <header type="string" class="Header" row="1" column="4"> <value>Age</value> </header> <header type="string" class="Header" row="1" column="5"> <value>Height</value> </header> <header type="string" class="Header" row="1" column="6"> <value>Weight</value> </header> </row> </output-head> <output-body> <row> <header type="double" class="RowHeader" row="2" column="1"> <value> 1</value> </header> <data type="string" class="Data" row="2" column="2"> <value>Alfred</value> </data> ... more xml tagged output... < /odsxml>

 

Commonly Used ODS Terminology

data component

is a form, similar to a SAS data set, that contains the results ( numbers and characters ) of a DATA step or PROC step that supports ODS.

table definition

is a set of instructions that describes how to format the data. This description includes but is not limited to

output object

is an object that contains both the results of a DATA step or PROC step and information about how to format the results. An output object has a name, label, and path . For example, the Basic Statistical Measurement table generated from the UNIVARIATE procedure is an output object. It contains the data component and formatted presentation of the mean, median, mode, standard deviation, variance, range, and interquartile range.

Note  

Although many output objects include formatting instructions, not all of them do. In some cases the output object consists of only the data component.

ODS destinations

are designations that produce specific types of output. ODS supports a number of destinations, including the following:

LISTING

produces traditional SAS output (monospace format).

Markup Languages

produce SAS output that is formatted using one of many different markup languages such as HTML (Hypertext Markup Language), XML (Extensible Markup Language), and LaTeX that you can access with a web browser. SAS supplies many markup languages for you to use ranging from DOCBOOK to TROFF. You can specify a markup language that SAS supplies or create one of your own and store it as a user-defined markup language.

DOCUMENT

produces a hierarchy of output objects that enables you to produce multiple ODS output formats without rerunning a PROC or DATA step and gives you more control over the structure of the output.

OUTPUT

produces a SAS data set.

Printer Family

produces output that is formatted for a high-resolution printer such as a PostScript (PS), PDF, or PCL file.

RTF

produces output that is formatted for use with Microsoft Word.

ODS output

ODS output consists of formatted output from any of the ODS destinations. For example, the OUTPUT destination produces SAS data sets; the LISTING destination produces listing output; the HTML destination produces output that is formatted in Hypertext Markup Language.

How Does ODS Work?

Components of SAS Output

The PROC or DATA step supplies raw data and the name of the table definition that contains the formatting instructions, and ODS formats the output. You can use the Output Delivery System to format output from individual procedures and from the DATA step in many different forms other than the default SAS listing output.

The following figure shows how SAS produces ODS output.

Figure 10.1: ODS Processing: What Goes in and What Comes Out

* List of Tagsets that SAS Supplies and Supports

 
Table 10.2: * List of Tagsets that SAS Supplies and Supports

CHTML

HTML4

SASIOXML

SASXMOH

CSVALL

HTMLCSS

SASREPORT

SASXMOIM

DEFAULT

IMODE

SASXML

SASXMOR

DOCBOOK

PHTML

SASXMOG

WML

EVENT_MAP

     

* List of Tagsets that SAS Supplies but Does Not Support

 
Table 10.3: Additional Tagsets that SAS Supplies but Does Not Support

COLORLATEX

LATEX

SHORT_MAP

TPL_STYLE_MAP

CSV

LATEX2

STYLE_DISPLAY

TROFF

CSVBYLINE

NAMEDHTML

STYLE_POPUP

WMLOLIST

GRAPH

ODSSTYLE

TEXT_MAP

 

GTABLEAPPLET

PYX

TPL_STYLE_LIST

 
Caution  

These tagsets are experimental tagsets. Do not use these tagsets in production jobs.

Features of ODS

ODS is designed to overcome the limitations of traditional SAS output and to make it easy to access and create the new formatting options. ODS provides a method of delivering output in a variety of formats, and makes the formatted output easy to access.

Important features of ODS include the following:

What Are the ODS Destinations?

Overview of ODS Destination Categories

ODS enables you to produce SAS procedure and DATA step output to many different destinations. ODS destinations are organized into two categories.

SAS Formatted destinations

produce output that is controlled and interpreted by SAS, such as a SAS data set, SAS output listing, or an ODS document.

Third-Party Formatted destinations

produce output which enables you to apply styles, markup languages, or enables you to print to physical printers using page description languages. For example, you can produce output in PostScript, HTML, XML, or a style or markup language that you created.

The following table lists the ODS destination categories, the destination that each category includes, and the formatted output that results from each destination.

Table 10.4: Destination Category Table

Category

Destinations

Results

SAS Formatted

DOCUMENT

ODS document

 

LISTING

SAS output listing

 

OUTPUT

SAS data set

Third-Party Formatted

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 future destinations are added to ODS, they automatically will become available to the DATA step and to all procedures that support ODS.

Definition of Destination-Independent Input

Destination-independent input means that one destination can support a feature even though another destination does not support it. In this case, the request is ignored by the destination that does not support it. Otherwise, ODS would support a small subset of features that are only common to all destinations. If this was true, then it would be difficult to move your reports from one output format to another output format. ODS provides many output formatting options, so that you can use the appropriate format for the output that you want. It is best to use the appropriate destination suited for your purpose.

The SAS Formatted Destinations

The SAS formatted destinations create SAS entities such as a SAS data set, a SAS output listing, or an ODS document. The statements in the ODS SAS Formatted category create the SAS entities.

The three SAS formatted destinations are:

DOCUMENT Destination

The DOCUMENT destination enables you to restructure, navigate, and replay your data in different ways and to different destinations as you like without needing to rerun your analysis or repeat your database query. The DOCUMENT destination makes your entire output stream available in "raw" form and accessible to you to customize. The output is kept in the original internal representation as a data component plus a table definition. When the output is in a DOCUMENT form, it is possible to rearrange, restructure, and reformat without rerunning your analysis. Unlike other ODS destinations, the DOCUMENT destination has a GUI interface. However, everything that you can do through the GUI, you can also do with batch commands using the ODS DOCUMENT statement and the DOCUMENT procedure.

Prior to SAS 9, each procedure or DATA step produced output that was sent to each destination that you specified. While you could always send your output to as many destinations as you wanted, you needed to rerun your procedure or data query if you decided to use a destination that you had not originally designated. The DOCUMENT destination eliminates the need to rerun procedures or repeat data queries by enabling you to store your output objects and replay them to different destinations.

LISTING Destination

The LISTING destination produces output that looks the same as the traditional SAS output. The LISTING destination is the default destination that opens when you start your SAS session. Thus ODS is always being used, even when you do not explicitly invoke ODS.

The LISTING destination enables you to produce traditional SAS output with the same look and presentation as it had in previous versions of SAS.

Because most procedures share some of the same table definitions, the output is more consistent. For example, if you have two different procedures producing an ANOVA table, they will both produce it in the same way because each procedure uses the same template to describe the table. However, there are four procedures that do not use a default table definition to produce their output: PRINT procedure, REPORT procedure, TABULATE procedure, and FREQ procedure's n-way tables. These procedures use the structure that you specified in your program code to define their tables.

OUTPUT Destination

The OUTPUT destination produces SAS output data sets. Because ODS already knows the logical structure of the data and its native form, ODS can output a SAS data set that represents exactly the same resulting data set that the procedure worked with internally. The output data sets can be used for further analysis, or for sophisticated reports in which you want to combine similar statistics across different data sets into a single table. You can easily access and process your output data sets using all of the SAS data set features. For example, you can access your output data using variable names and perform WHERE-expression processing just as you would process data from any other SAS data set.

The Third-Party Formatted Destinations

The third-party formatted destinations enable you to apply styles to the output objects that are used by applications other than SAS. For example, these destinations support attributes such as "font" and " color ."

Note  

For a list of style elements and valid values, see the style elements table in the The Complete Guide to the SAS Output Delivery System .

The four categories of third-party formatted destinations are:

What Controls the Formatting Features of Third-Party Formats?

All of the formatting features that control the appearance of the third-party formatted destinations beyond what the LISTING destination can do are controlled by two mechanisms:

The ODS statement options control three features:

  1. Features that are specific to a given destination, such as stylesheets for HTML.

  2. Features that are global to the document, such as AUTHOR and table of contents generation.

  3. Features that we expect users to change on each document, such as the output file name.

The ODS style attributes control the way that individual elements are created. Attributes are aspects of a given style, such as type face, weight, font size , and color. The values of the attributes collectively determine the appearance of each part of the document to which the style is applied. With style attributes, it is unnecessary to insert destination-specific code (such as raw HTML) into the document. Each output destination will interpret the attributes that are necessary to generate the presentation of the document. Because not all destinations are the same, not all attributes can be interpreted by all destinations. Style attributes that are incompatible with a selected destination are ignored. For example, PostScript does not support active links, so the URL= attribute is ignored when producing PostScript output.

ODS Destinations and System Resources

ODS destinations can be open or closed. You open and close a destination with the appropriate ODS statement. When a destination is open, ODS sends the output objects to it. An open destination uses system resources even if you use the selection and exclusion features of ODS to select or exclude all objects from the destination. Therefore, to conserve resources, close unnecessary destinations. For more information about using each destination, see the topic on ODS statements in the The Complete Guide to the SAS Output Delivery System .

By default, the LISTING destination is open and all other destinations are closed. Consequently, if you do nothing, your SAS programs run and produce listing output looking just as they did in previous releases of SAS before ODS was available.

What Are Table Definitions, Table Elements, and Table Attributes?

A table definition describes how to generate the output for a tabular output object. (Most ODS output is tabular.) A table definition determines the order of column headers and the order of variables , as well the overall look of the output object that uses it. For information about customizing the table definition, see the topic on the TEMPLATE procedure in the The Complete Guide to the SAS Output Delivery System .

In addition to the parts of the table definition that order the headers and columns, each table definition contains or references table elements . A table element is a collection of table attributes that apply to a particular header, footer, or column. Typically, a table attribute specifies something about the data rather than about its presentation. For example, FORMAT specifies the SAS format, such as the number of decimal places. However, some table attributes describe presentation aspects of the data, such as how many blank characters to place between columns.

Note  

The attributes of table definitions that control the presentation of the data have no effect on output objects that go to the LISTING or OUTPUT destination. However, the attributes that control the structure of the table and the data values do affect listing output.

For information on table attributes, see the section on table attributes in the The Complete Guide to the SAS Output Delivery System .

What Are Style Definitions, Style Elements, and Style Attributes?

To customize the output at the level of your entire output stream in a SAS session, you specify a style definition. A style definition describes how to generate the presentation aspects (color, font face, font size, and so on) of the entire SAS output. A style definition determines the overall look of the documents that use it.

Each style definition is composed of style elements . A style element is a collection of style attributes that apply to a particular part of the output. For example, a style element may contain instructions for the presentation of column headers, or for the presentation of the data inside the cells . Style elements may also specify default colors and fonts for output that uses the style definition.

Each style attribute specifies a value for one aspect of the presentation. For example, the BACKGROUND= attribute specifies the color for the background of an HTML table or for a colored table in printed output. The FONT_STYLE= attribute specifies whether to use a Roman or an italic font. For information on style attributes, see the section on style attributes in the The Complete Guide to the SAS Output Delivery System .

Note  

Because style definitions control the presentation of the data, they have no effect on output objects that go to the LISTING or OUTPUT destination.

What Style Definitions Are Shipped with SAS Software?

Base SAS software is shipped with many style definitions. To see a list of these styles, you can view them in the SAS Explorer Window, use the TEMPLATE procedure, or use the SQL procedure.

For more information on how ODS destinations use styles and how you can customize styles, see the section on the DEFINE STYLE statement in the The Complete Guide to the SAS Output Delivery System .

How Do I Use Style Definitions with Base SAS Procedures?

Changing SAS Registry Settings for ODS

Overview of ODS and the SAS Registry

The SAS registry is the central storage area for configuration data that ODS uses. This configuration data is stored in a hierarchical form, which works in a similar manner to the way directory-based file structures work under UNIX, Windows, VMS, and the z/OS UNIX system. However, the SAS registry uses keys and subkeys as the basis for its structure, instead of using directories and subdirectories, like similar file systems in DOS or UNIX. A key is a word or a text string that refers to a particular aspect of SAS. Each key may be a place holder without values or subkeys associated with it, or it may have many subkeys with associated values. For example, the ODS key has DESTINATIONS, GUI, ICONS, and PREFERENCES subkeys. A subkey is a key inside another key. For example, PRINTER is a subkey of the DESTINATIONS subkey .

Display 10.5: SAS Registry of ODS Subkeys

Changing Your Default HTML Version Setting

By default, the SAS registry is configured to generate HTML4 output when you specify the ODS HTML statement. To permanently change the default HTML version, you can change the setting of the HTML version in the SAS registry.

Caution  

If you make a mistake when you modify the SAS registry, then your system might become unstable or unusable. You will not be warned if an entry is incorrect. Incorrect entries can cause errors, and can even prevent you from bringing up a SAS session. For more information about how to configure the SAS registry, see the SAS registry section in SAS Language Reference: Concepts .

To change the default setting of the HTML version in the SAS registry:

  1. Select or Issue the command REGEDIT .

  2. Select

  3. Select or Click the right mouse button and select MODIFY . The Edit String Value window appears.

  4. Type the HTML version in the Value Data text box and select OK .

Display 10.6: SAS Registry Showing HTML Version Setting

Changing ODS Destination Default Settings

ODS destination subkeys are stored in the SAS registry. To change the values for these destinations subkeys:

  1. Select

  2. Select a destination subkey

  3. Select a subkey in the Contents of window

  4. Select or Click the right mouse button and select MODIFY .

  5. Type in the Value Data entry into the Edit Value String or Edit Signed Integer Value window and select OK .

Display 10.7: Registry Editor Window

Категории