Previous Page | Next Page

Dictionary of ODS Language Statements

ODS OUTPUT Statement



Produces a SAS data set from an output object and manages the selection and exclusion lists for the OUTPUT destination.
Valid: anywhere
Category: ODS: SAS Formatted

Syntax
Actions
Required Arguments
Details
Merging Dissimilar Output Objects into One Data Set
Examples
Example 1: Creating a Combined Output Data Set
Example 2: Using Different Procedures to Create a Data Set from Similar Output Objects
Example 3: Creating a Data Set with and without The MATCH_ALL Option

Syntax

ODS OUTPUT action;
ODS OUTPUT data-set-definition(s);


Actions

An action can be one of the following:

CLEAR

sets the list for the OUTPUT destination to EXCLUDE ALL.

CLOSE

closes the OUTPUT destination. When an ODS destination is closed, ODS does not send output to that destination. Closing a destination frees some system resources.

SHOW

writes to the SAS log the current selection or exclusion list for the OUTPUT destination. If the list is the default list (EXCLUDE ALL), then SHOW also writes the current overall selection or exclusion list.


Required Arguments

data-set-definition

provides instructions for turning an output object into a SAS data set. ODS maintains a list of these definitions. This list is the selection list for the OUTPUT destination. For information about how ODS manages this list, see Selection and Exclusion Lists. Each data-set-definition has the following form:

output-object-specification<=data-set>
output-object-specification

has the following form:

output-object<(MATCH_ALL<=macro-var-name> PERSIST=PROC | RUN)>
output-object

identifies one or more output objects to turn into a SAS data set.

To specify an output object, you need to know which output objects your SAS program produces. The ODS TRACE statement writes to the SAS log a trace record that includes the path, the label, and other information about each output object that is produced. For more information, see the ODS TRACE statement. Output Objects can be specified as the following:

  • a full path. For example,

    Univariate.City_Pop_90.TestsForLocation
    is the full path of the output object.
  • a partial path. A partial path consists of any part of the full path that begins immediately after a period (.) and continues to the end of the full path. For example, if the full path is

    Univariate.City_Pop_90.TestsForLocation
    then the partial paths are:
     City_Pop_90.TestsForLocation
     TestsForLocation
  • a label that is enclosed in quotation marks.

    For example,

    "Tests For Location"
  • a label path. For example, the label path for the output object is

    "The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"

    Note:   The trace record shows the label path only if you specify the LABEL option in the ODS TRACE statement.  [cautionend]

  • a partial label path. A partial label path consists of any part of the label that begins immediately after a period (.) and continues to the end of the label. For example, if the label path is

    "The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
    then the partial label paths are:
    "CityPop_90"."Tests For Location" 
    "Tests For Location"
  • a mixture of labels and paths.

  • any of the partial path specifications, followed by a pound sign (#) and a number. For example, TestsForLocation#3 refers to the third output object that is named TestsForLocation .

Tip: To create multiple data sets from the same output object, list the output object as many times as you want. Each time that you list the output object, specify a different data set.
MATCH_ALL=<macro-var-name>

creates a new data set for each output object. For an explanation of how ODS names these data sets, see the discussion of data-set.

macro-var-name

specifies the macro variable where a list of all the data sets that are created are stored. Thus, if you want to concatenate all the data sets after the PROC step, then you can use the macro variable to specify all the data sets in a DATA step.

Tip: The MATCH_ALL option is not needed to merge conflicting output objects into one data set.
CAUTION:
A data set that is produced by SAS 9.1 without MATCH_ALL will not necessarily be identical to a data set produced by SAS 9.0 with MATCH_ALL and then concatenated in a DATA step. With SAS 9.0, merging dissimilar output objects with the MATCH_ALL option could result in missing columns or truncated variables. With SAS 9.1, these restrictions do not apply. For more information about merging output objects, seeMerging Dissimilar Output Objects into One Data Set .   [cautionend]
PERSIST=PROC | RUN

determines when ODS closes any data sets that it is creating, and determines when ODS removes output objects from the selection list for the OUTPUT destination.

PROC

maintains the list of definitions even after the procedure ends, until you explicitly modify it. To modify the list, use ODS OUTPUT with one or more data-set-specifications. To set the list for the OUTPUT destination to EXCLUDE ALL, use the following statement:

ods output clear;
RUN

maintains the list of definitions and keeps open the data sets that it is creating even if the procedure or DATA step ends, or until you explicitly modify the list.

See also: How ODS Determines the Destinations for an Output Object
data-set

names the SAS output data set. You can use a one-level or two-level (with a libref) name.

If you are creating a single data set, then the ODS OUTPUT statement simply uses the name that you specify. If you are creating multiple data sets with MATCH_ALL, then the ODS OUTPUT statement appends numbers to the name. For example, if you specify test as data-set and you create three data sets, then ODS names the first data set test. The additional data sets are named test1 and test2.

Note:   If you end the filename with a number, then ODS begins incrementing the name of the file with that number. For example, if you specify may5 as data-set and you create three data sets, then ODS names the first data set may5. The additional data sets are named may6 and may7.   [cautionend]

Default: If you do not specify a data set, then ODS names the output data set DATAn, where n is the smallest integer that makes the name unique.
Tip: You can specify data set options in parentheses immediately after data-set.
NOWARN

suppresses the warning that an output object was requested but not created.

SHOW

functions just like the ODS SHOW statement except that it writes only the selection or exclusion list for the OUTPUT destination.


Details


Merging Dissimilar Output Objects into One Data Set

By default, the ODS OUTPUT statement puts all output objects that have the same output-path into one SAS data set, regardless of any conflicting variables in the output objects. Variables created by a later output object will get a value of missing in the observations created by the earlier output object. Variables created by an earlier output object that do not exist in a subsequent output object will get a value of missing in the observations added by the later output object. If a variable created by an output object has a different type than a variable with the same name created by an earlier output object, it will be added to the output data set using a new name formed by adding a numeric suffix.


Examples


Example 1: Creating a Combined Output Data Set

ODS features:

ODS _ALL_ CLOSE statement

ODS HTML statement:

BODY=

CONTENTS=

FRAME=

PAGE=

ODS LISTING statement:

CLOSE

ODS OUTPUT statement

Other SAS features:

PROC FORMAT

PROC PRINT

PROC TABULATE

KEEP= data set option

Data Sets:

See Creating the Energy Data Set.


Program Description

This example routes two output objects that PROC TABULATE produces to both the OUTPUT destination and the HTML destination. The result is two output objects that are combined by the ODS OUTPUT statement to create an output data set formatted as HTML output by the ODS HTML statement.

Note:   This example uses filenames that might not be valid in all operating environments. To successfully run the example in your operating environment, you might need to change the file specifications. See ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]


Program

 Note about code
proc format;
   value regfmt 1='Northeast'
                2='South'
                3='Midwest'
                4='West';
   value divfmt 1='New England'
                2='Middle Atlantic'
                3='Mountain'
                4='Pacific';
   value usetype 1='Residential Customers'
                 2='Business Customers';
run;
 Note about code
ods listing close;
 Note about code
ods output Table=energyoutput(keep=region division type expenditures_sum);
 Note about code
ods html body='your_body_file.html'
        frame='your_frame_file.html'
     contents='your_contents_file.html'
        page='your_page_file.html';
 Note about code
proc tabulate data=energy format=dollar12.;
   by region;
   class division type;
   var expenditures;
   table division,
         type*expenditures;
   format region regfmt. division divfmt. type usetype.;
   title 'Energy Expenditures for Each Region';
   title2 '(millions of dollars)';
run;

 Note about code
ods html body='your_body_file_2.html';
 Note about code
proc print data=energyoutput noobs;
   title 'Combined Output Data Set';
run;
 Note about code
ods _all_ close;
ods listing;

HTML Output

Combined Data Set

 Note about figure

[Combined Data Set]

Output Objects Created by PROC TABULATE

 Note about figure

[Output Objects Created by PROC TABULATE]


Example 2: Using Different Procedures to Create a Data Set from Similar Output Objects

ODS features:

ODS HTML statement:

BODY=

CONTENTS=

FRAME=

ODS OUTPUT statement

ODS SELECT statement

Other SAS features:

PROC GLM

PROC PRINT

PROC REG

Data set:

Iron.


Program Description

This example creates and prints a data set that is created from the parameter estimates that PROC REG and PROC GLM generate. These procedures are part of SAS/STAT software.

Note:   This example uses filenames that might not be valid in all operating environments. To successfully run the example in your operating environment, you might need to change the file specifications. See ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]


Program

 Note about code
 options nodate pageno=1 pagesize=60 linesize=72;
 Note about code
ods html body='parameter-estimates-body.htm'
        frame='parameter-estimates-frame.htm'
     contents='parameter-estimates-contents.htm';
 Note about code
ods select ParameterEstimates(persist);
 Note about code
ods output ParameterEstimates(persist=proc)=IronParameterEstimates;
 Note about code
proc reg data=iron;
   model loss=fe;
title 'Parameter Estimate from PROC REG';
run;
quit;

proc glm data=iron;
   model loss=fe;
title 'Parameter Estimate from PROC GLM';
run;
quit;
 Note about code
ods select all;
 Note about code
proc print data=IronParameterEstimates noobs;
title 'PROC PRINT Report of the Data set from PROC REG';
run;
 Note about code
ods _all_ close;

HTML Output

HTML Output from the REG, GLM, and PRINT Procedures

 Note about figure

[HTML Output from the REG, GLM, and PRINT Procedures]


Listing Output

Listing Output from the REG, GLM, and PRINT Procedures

                    Parameter Estimate from PROC REG                   1

                           The REG Procedure
                             Model: MODEL1
                       Dependent Variable: Loss

                          Parameter Estimates

                       Parameter       Standard
  Variable     DF       Estimate          Error    t Value    Pr > |t|

  Intercept     1      129.78660        1.40274      92.52      <.0001
  Fe            1      -24.01989        1.27977     -18.77      <.0001
                    Parameter Estimate from PROC GLM                   2

                           The GLM Procedure

Dependent Variable: Loss

                                     Standard
   Parameter         Estimate           Error    t Value    Pr > |t|

   Intercept      129.7865993      1.40273671      92.52      <.0001
   Fe             -24.0198934      1.27976715     -18.77      <.0001
        PROC PRINT Report of the Data Set Created from PROC GLM and PROC REG 3

  Model  Dependent Variable  DF    Estimate      StdErr  tValue  Probt

  MODEL1   Loss    Intercept  1   129.78660     1.40274   92.52 <.0001
  MODEL1   Loss    Fe         1   -24.01989     1.27977  -18.77 <.0001

Example 3: Creating a Data Set with and without The MATCH_ALL Option

ODS features:

ODS HTML statement:

BODY=

ODS LISTING

ODS OUTPUT statement:

MATCH_ALL

ODS TRACE statement

Other SAS features:

PROC PRINT

PROC REG

Data set:

See Model.


Program Description

This example illustrates the differences in the data sets created by specifying the MATCH_ALL option and by not specifying the MATCH_ALL option. The first program creates a merged data set by specifying the MATCH_ALL option. The second program creates a merged data set without specifying the MATCH_ALL option.

The data sets that are printed are parameter estimates that PROC REG generates. The PROC REG procedure is part of SAS/STAT software.

Note:   This example uses filenames that might not be valid in all operating environments. To successfully run the example in your operating environment, you might need to change the file specifications. See ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]


Program 1

 Note about code
ods listing close;
 Note about code
ods output SelectionSummary(match_all=list) = summary;
title1 'Using the MATCH_ALL Option Produces Two Data Sets With Different Columns';
 Note about code
ods trace on;
proc reg data=model;
  model r33=a b r4 r8 c d e r23 r24 r29/ selection=forward
            sle=.5 maxstep=3;
  model r33=a b r4 r8 c d e r23 r24 r29/ selection=backward
            sls=0.05 maxstep=3;
run;
ods trace off;
 Note about code
ods html body='combined.html';
 Note about code
title2 'The First Data Set Has the VARENTERED Column';
proc print data=summary;
run;

title1;
title2 'The Second Data Set Has the VERREMOVED Column';
proc print data=summary1;
run;
 Note about code
data summarym;
   set &list;
run;
 Note about code
title1;
title2 'The Merged Data Set Has Both Columns';
proc print data=summarym;
run;
 Note about code
ods html close; 

HTML Output

Three Data Sets Created When Using the MATCH_ALL Option

 Note about figure

[Three Data Sets Created When Using the MATCH_ALL Option]


Program 2

 Note about code
ods output SelectionSummary=summary;
title1 'Without the MATCH_ALL Option, ODS Produces a Single Data Set With All 
        Of the Columns';
 Note about code
ods trace on;
proc reg data=model;
  model r33=a b r4 r8 c d e r23 r24 r29/ selection=forward
            sle=.5 maxstep=3;
  model r33=a b r4 r8 c d e r23 r24 r29/ selection=backward
            sls=0.05 maxstep=3;
run;
ods trace off;
 Note about code
ods html body='combined2.html';
 Note about code
proc print data=summary;
run;
 Note about code
ods html close;

HTML Output

Using the ODS OUTPUT Statement Without the MATCH_ALL Option to Combine Data Sets

 Note about figure

[Using the ODS OUTPUT Statement Without the MATCH_ALL Option to Combine Data Sets]

Previous Page | Next Page | Top of Page