Chapter Contents

Previous

Next
The ODS Statements

ODS OUTPUT Statement


Creates a SAS data set from an output object and manages the selection and exclusion lists for the Output destination.

Featured in: Creating Output Data Sets


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

To do this ... Use this action
Set the list for the Output destination to EXCLUDE ALL CLEAR
Close the Output destination CLOSE
Write to the SAS log the current selection or exclusion list for the Output destination SHOW


Actions

An action takes some action regarding selection and exclusion lists, or closes the Output destination. 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 an unneeded 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), SHOW also writes the current overall selection or exclusion list.
Restriction: The Output destination must be open for this action to take effect.


Required Arguments

If you do not specify an action, you must specify a data-set-definition.

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 on how ODS manages this list, see Modifying Selection and Exclusion Lists. Each data-set-definition has the following form:
output-object-specification<=SAS-data-set>
where

output-object-specification
has the following form:
output-object<(MATCH_ALL<=macro-var-name> PERSIST=PROC | RUN)>
where

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

To specify an output object, you need to know what 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. (See ODS TRACE Statement.) You can specify an output object as

  • a full path (shown as the path in the trace record).

  • 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 instance, if the full path is
       Univariate.City_Pop_90.TestsForLocation
    partial paths are
       City_Pop_90.TestsForLocation
       TestsForLocation

  • a label (surrounded by quotation marks).

  • a label path. (The trace record shows the label path only if you specify the LABEL option in the ODS TRACE statement.)

  • 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 instance, if the label path is
       "The UNIVARIATE Procedure"."CityPop_90"
       ."Tests For Location"
    partial label paths are
       "CityPop_90"."Tests For Location" 
       "Tests For Location"

  • a mixture of labels and paths.

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

By default, the ODS OUTPUT statement tries to put all output objects that have the same output-path into one SAS data set. Sometimes this process is problematic because the structure of the output object changes after the data set has been opened. For instance, some data-dependent output objects may have a different number of columns than other output objects identified by the same output-path. In this case, the columns that are in the first output object will determine the variables that are in the data set. Two difficulties may arise:

  • If subsequent output objects do not have a column that is in the first output object, the observations for those output objects have missing values for the variables that the ODS OUTPUT statement creates from those columns.

  • If subsequent output objects have additional columns that are not in the first output object, those columns cannot be added to the data set because the program data vector has already been written.

If the ODS OUTPUT statement has a problem putting all output objects into one data set, it returns a warning.
Tip: To create multiple data sets from the same output object, list the output object as many times as you wish. Each time that you list the output object, specify a different data set.
Featured in: Creating Output Data Sets

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 SAS-data-set.

If you specify macro-var-name, the system stores a list of all the data sets that it creates in the macro variable that you specify. Thus, if you want to concatenate all the data sets after the PROC step, you can use the macro variable to specify all the data sets in a DATA step.
Featured in: Creating Output Data Sets

PERSIST=PROC | RUN
determines when ODS closes any data sets that it is creating and when it removes output objects from the selection list for the Output destination.

PROC
maintains the list of definitions even if the procedure or DATA step 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;
Restriction: Only effective when MATCH_ALL is in effect (and you are, therefore, creating a data set for each output object).
Featured in: Creating Data Sets from Similar Output Objects from Different Procedures

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

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

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

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

Note:   If you end the file name with a digit, ODS begins incrementing with that digit. For example, if you specify may5 as SAS-data-set and you create three data sets, 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, 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 SAS-data-set.
Featured in: Creating Output Data Sets

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


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.