You may recall in the first part of Stat 483 that we used an OUTPUT statement in the MEANS procedure to create a data set containing summary statistics, such as means and standard deviations. We'll see in this section that we could have alternatively used ODS to first save the summary statistics and then send it to the OUTPUT destination. In fact, we can use ODS to save just about any part of any procedure's output!
Example 24.11 Section
The following program uses an ODS OUTPUT statement to create a temporary SAS data set called summout from the Summary output object created by the MEANS procedure, and then prints the resulting summout data set:
PROC MEANS data = golfbypar;
title 'Pennsylvania Golf Courses by Par';
ODS OUTPUT Summary = summout;
PROC PRINT data = summout NOOBS;
title 'The summout data set';
Now, something that might not be obvious from this code is that the name of the output object, Summary, was determined from first tracing the MEANS procedure. If you refer back to the information SAS displayed in the log for Example 24.7, you can see that, since we want to capture all of the output from the MEANS procedure, the desired output object is called Summary. The ODS OUTPUT statement tells SAS that we want to save the data contained in the Summary output object in a data set called summout. Of course, the PRINT procedure then tells SAS to print the summout data set. Launch and run the SAS program, and review the output to convince yourself that the summout data set does indeed contain the data summarized by the MEANS procedure.
You do need to be careful where you put ODS statements in your program. For example, if rather than putting the ODS OUTPUT statement just before the MEAN procedure's RUN statement, we had instead put it after the MEAN procedure's RUN statement and before the PRINT procedure's PROC PRINT statement, we would not have captured the Summary data set. Instead, we would get the following Warning message:
WARNING: Output 'Summary' was not created. Make sure that the output Object name, label, or path is spelled corectly. Also Verify that the appropriate procedute options are used to produce the request output object. For example, verify that the NOPRINT option is not used
You might want to move the ODS statement as described and re-run the SAS program just to see this for yourself.