Вы находитесь на странице: 1из 13

the power to know

DAY 8

Output Delivery System (ODS):


- Fundamentals of the ODS
Overview:
Output Delivery System (ODS) which determines where the output should go and
what it should look like when it gets there. Whenever you dont specify a
destination, your output will be sent, by default, to the listing. The listing is what
you see in the Output window if you use the SAS windowing environment, or in
the listing or output file if you use batch mode. Here are the major destinations:

LISTING
OUTPUT
HTML
RTF
PRINTER
PS
PCL
PDF
MARKUP
DOCUMENT

standard SAS output


SAS output data set
Hypertext Markup Language
Rich Text Format
high resolution printer output
PostScript
Printer Control Language
Portable Document Format
markup languages including XML
output document

Continued
Style and table templates:
The two most common types of templates are table templates and style templates
(also called table definitions and style definitions).

A table template specifies the basic structure of your output (which variable will be
in the first column?), while a style template specifies how the output will look (will
the headers be blue or red?).

To view a list of the style templates available on your system, submit the following
PROC TEMPLATE statements, and look in the output window for the list:
PROC TEMPLATE;
LIST STYLES;
RUN;

Output Delivery System (ODS):


- Tracing and Selecting Procedure Output
Overview:
When ODS receives data from a procedure, it combines that data with a table
template. Together the data and corresponding table template are called an
output object.
Every output object has a name. You can find the names of output objects using
the ODS TRACE statement, and then use an ODS SELECT (or ODS EXCLUDE)
statement to choose just the output objects you want.

The ODS TRACE statement: The ODS TRACE statement tells SAS to print
information about output objects in your SAS log. There are two ODS TRACE
statements: one to turn on the trace, and one to turn it off. Here is how to use
these statements in a program:

Continued
Example:

Big Zac, red, 80, 5


Delicious, red, 80, 3
Dinner Plate, red, 90, 2
Goliath, red, 85, 1.5
Mega Tom, red, 80, 2
Big Rainbow, yellow, 90, 1.5
Pineapple, yellow, 85, 23
The following program creates a data set named GIANT, and then traces PROC
MEANS using ODS TRACE ON and ODS TRACE OFF statements:
DATA giant;
INFILE 'c:\MyRawData\Tomatoes.dat' DSD;
INPUT Name :$15. Color $ Days Weight;
* Trace PROC MEANS;
ODS TRACE ON;
PROC MEANS DATA = giant; BY Color;
RUN;
ODS TRACE OFF:

Continued
Output:

Continued
The ODS SELECT statement Once you know the names of the output objects,
you can use an ODS SELECT (or EXCLUDE) statement to choose just the
output objects you want. The general form of an ODS SELECT statement is:

where output-object-list is the name, label, or path of one or more output


objects separated by spaces. By default, an ODS SELECT statement lasts for
only one PROC step, so by placing the SELECT statement after the PROC
statement and before the RUN, you are sure to capture the correct output.
ODS EXCLUDE statements work the same way except you list output objects
that you want to eliminate.

Continued
Example:
PROC MEANS DATA = giant;
BY Color;
TITLE 'Red Tomatoes';
ODS SELECT Means.ByGroup1.Summary;
RUN;

Output:

Output Delivery System (ODS):


- Creating SAS Data Sets from Procedure Output
Overview:
Sometimes you may want to put the results from a procedure into a SAS data set.
Some procedures have OUTPUT statements, or OUT= options, allowing you to
save the results as a SAS data set. But with ODS you can save almost any part
of procedure output as a SAS data set by sending it to the OUTPUT destination.
First you use an ODS TRACE statement to determine the name of the output
object you want. Then you use an ODS OUTPUT statement to send that object to
the OUTPUT destination.

The ODS OUTPUT statement Here is the general form of a basic ODS OUTPUT
statement:

where output-object is the name, label or path of the piece of output you want
to save, and new-data- set is the name of the SAS data set you want to create.

Continued
Example:
Here is an excerpt from a SAS log showing the trace produced by PROC
TABULATE. TABULATE produces one output object named Table.

DATA giant;
INFILE 'c:\MyRawData\Tomatoes.dat' DSD;
INPUT Name :$15. Color $ Days Weight;
PROC TABULATE DATA = giant;
CLASS Color;
VAR Days Weight;
TABLE Color ALL, (Days Weight) * MEAN;
TITLE 'Standard TABULATE Output';
ODS OUTPUT Table = tabout;
RUN;
PROC PRINT DATA = tabout;
TITLE 'OUTPUT SAS Data Set from TABULATE'; RUN;

Continued
Output:

Output Delivery System (ODS):


- Using ODS Statements to Create HTML Output
Overview:
Sometimes you may want to put the results from a procedure into a SAS data set.
Some procedures have OUTPUT statements, or OUT= options, allowing you to
save the results as a SAS data set. But with ODS you can save almost any part
of procedure output as a SAS data set by sending it to the OUTPUT destination.
First you use an ODS TRACE statement to determine the name of the output
object you want. Then you use an ODS OUTPUT statement to send that object to
the OUTPUT destination.

The ODS OUTPUT statement Here is the general form of a basic ODS OUTPUT
statement:

where output-object is the name, label or path of the piece of output you want
to save, and new-data- set is the name of the SAS data set you want to create.

Exploring Your SAS Environment (Self-Study)

Вам также может понравиться