How Do I Create Variables and/or Datasets from My PROC Output?

A researcher may want a table containing output from a procedure such as PROC GENMOD but the OUT= option often does not include all the information one sees on the listing.

For example, p-values are not in the dataset created by the OUT= option. However, SAS creates a data set for each output item, even if you do not see it in the OUT= dataset. ODS will create datasets for any and all procedure output.

ODS creates an output object with two components:

  • A data object containing the raw data for the PROC output
  • A template describing how the above data object is presented in the listing

Identifying Output Variables

ODS TRACE Statement:

Before using ODS to create datasets, you need to know what files your PROC creates and their name. This is easy with the ODS TRACE statement.


Turns on the trace record.

Turns off the trace record.

ODS produces an object by combining the data component with a template and provides the following information in the SAS log:

Name is the name of the output object. You use the name to make a dataset from the output object.
Label briefly describes the contents of the output object. This label also identifies the output object in the Results window.
Template is the name of the template that ODS uses to format the output object. You can use PROC TEMPLATE to modify the template.
Path is the path of the output object. You can use the path to reference this output object. For example, you could use the path in the ODS OUTPUT statement to make a data set from the output, or you could use it in an ODS SELECT or an ODS EXCLUDE statement.

The SAS log can get long with procedures that produce a substantial amount of output, such as PROC GLM. The log below shows the PROC GLM and a portion of the output using ODS TRACE ON. While informative, it can be tiresome to match the output with the corresponding section in the listing. You can use an option to embed this information in the listing. This may be more useful in connecting the trace information to the listing output.

ODS Trace ON and OFF Statements

Use the LISTING option with TRACE ON to see the same information in the listing rather than the log. The figure below shows a portion of the listing using ODS TRACE ON / LISTING.


Creating Temporary Datasets to Use in Your Program

Now that you know what datasets SAS creates during procedures, you can use these datasets to customize the output. The first thing you need to do is save the SAS output as datasets you can access using ODS OUTPUT, a simple statement that precedes the PROC.

ODS OUTPUT Statement:

ODS OUTPUT [Procedure Output Object] = [your dataset]

Output-object-specification = dataset


Suppose we want to save the estimates from the PROC GLM below. We can add an ODS OUTPUT statement to send the output object, Estimates, to a dataset called est_c01 and print it.

ODS OUTPUT Statement

The dataset, est_c01, has one observation and five variables:

variable Estimate StdErr tValue Probt
c01 14.280539 309.555748 0.05 0.9632