Dictionary of ODS Language Statements |
Valid: | anywhere |
Category: | ODS: SAS Formatted |
Syntax |
ODS OUTPUT action; |
ODS OUTPUT data-set-definition(s); |
An action can be one of the following:
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.
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.
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<(MATCH_ALL<=macro-var-name> PERSIST=PROC | RUN)> |
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.TestsForLocationis 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.TestsForLocationthen the partial paths are:
City_Pop_90.TestsForLocation TestsForLocation
a label that is enclosed in quotation marks.
"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.
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"
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. |
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.
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.
|
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.
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;
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 |
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.
suppresses the warning that an output object was requested but not created.
functions just like the ODS SHOW statement except that it writes only the selection or exclusion list for the OUTPUT destination.
Details |
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 |
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.
ods listing close; |
ods output Table=energyoutput(keep=region division type expenditures_sum); |
ods html body='your_body_file.html' frame='your_frame_file.html' contents='your_contents_file.html' page='your_page_file.html'; |
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;
ods html body='your_body_file_2.html'; |
proc print data=energyoutput noobs; title 'Combined Output Data Set'; run; |
ods _all_ close; ods listing; |
Combined Data Set
Output Objects Created by PROC TABULATE
| |||||||
Iron.
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.
options nodate pageno=1 pagesize=60 linesize=72; |
ods html body='parameter-estimates-body.htm' frame='parameter-estimates-frame.htm' contents='parameter-estimates-contents.htm'; |
ods select ParameterEstimates(persist); |
ods output ParameterEstimates(persist=proc)=IronParameterEstimates; |
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; |
ods select all; |
proc print data=IronParameterEstimates noobs; title 'PROC PRINT Report of the Data set from PROC REG'; run; |
ods _all_ close; |
HTML Output from the REG, GLM, and PRINT Procedures
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
| |||
| |||
See Model.
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.
ods listing close; |
ods output SelectionSummary(match_all=list) = summary; title1 'Using the MATCH_ALL Option Produces Two Data Sets With Different Columns'; |
ods html body='combined.html'; |
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; |
data summarym; set &list; run; |
title1; title2 'The Merged Data Set Has Both Columns'; proc print data=summarym; run; |
ods html close; |
Three Data Sets Created When Using the MATCH_ALL Option
ods output SelectionSummary=summary; title1 'Without the MATCH_ALL Option, ODS Produces a Single Data Set With All Of the Columns'; |
ods html body='combined2.html'; |
proc print data=summary; run; |
ods html close; |
Using the ODS OUTPUT Statement Without the MATCH_ALL Option to Combine Data Sets
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.