Statistical programmers often have to use the results from one SAS procedure as the input to another SAS procedure. Because ODS enables you to you to create a SAS data set from any ODS table or graph, it is easy to obtain a data set that contains the value of any statistic that is produced by any SAS procedure. All you need to do is submit the ODS OUTPUT statement before calling the procedure, like this:
ODS OUTPUT tablename; /* replace with ODS table name */
There's just one problem: You might not know the name of the ODS table!
There are two ways to discover the name. The "experimental way" is to submit ODS TRACE ON, run the procedure, and then check the SAS log, which reports the name of every table and graph that the procedure produced. Here's an example:
ods trace on; proc logistic data=Sashelp.Class; model sex = height weight; run; ods trace off;
The names of the ODS objects are output sequentially in the same order as the procedure output. Consequently, if you want the fifth table in the output, then you can count down to the fifth name in the log and discover that the fifth table is named the FitStatistics table.
There are two problems with this experimental approach. First, it is inefficient because it requires that you actually run a SAS procedure before you can discover the name of an ODS object. For a long-running procedure, this isn't optimal. Second, it assumes that you know which option to specify in order to produce the table. If a colleague says to you, "run PROC DISCRIM and save the PostResub table to a SAS data set," you might not know which option produces the PostResub table.
The second way to discover the name of ODS tables and graphs is to look them up in the documentation. This method requires several mouse clicks to locate the right book and chapter, and then you can click on the "Details" section and the "ODS Table Names" subsection. However, I recently discovered a page of the ODS User's Guide that simplifies the process. Here is a fast way to find the name of ODS tables:
- Go to the first Appendix of the ODS User's Guide.
- Select the product, such as the ODS table names for SAS/STAT procedures
- Select the procedure.
You are taken directly to the "ODS Table Names" section of the documentation, which lists the ODS tables and the options that produce them.
Thanks to the SAS documentation team who put together these pages that link to the analytics documentation from the ODS documentation. It's a real timesaver! Unfortunately, there are a few SAS/STAT procedures that are missing from the list (GENMOD and GLIMMIX among them), but I'm sure these small omissions will be corrected in subsequent documentation.
I'll leave you with a research question: which Base SAS or SAS/STAT procedure is capable of producing the most ODS tables? My bet is on PROC FREQ, which produces about 100 tables, but I don't know for sure. Does anyone know a procedure that can produce more?