Find the ODS table names produced by any SAS procedure

3

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:

  1. Go to the first Appendix of the ODS User's Guide.
  2. Select the product, such as the ODS table names for SAS/STAT procedures
  3. 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?

Share

About Author

Rick Wicklin

Distinguished Researcher in Computational Statistics

Rick Wicklin, PhD, is a distinguished researcher in computational statistics at SAS and is a principal developer of SAS/IML software. His areas of expertise include computational statistics, simulation, statistical graphics, and modern methods in statistical data analysis. Rick is author of the books Statistical Programming with SAS/IML Software and Simulating Data with SAS.

3 Comments

  1. Another excellent and informative post, Rick!

    I'd like to offer two comments/suggestions, to it, please. First, it's a good idea, in my experience, to submit the ODS TRACE OFF; command after the PROC "step" of interest so you don't fill up your LOG with unwanted information from additional PROCs in your program. ODS TRACE ON remains in effect for the rest of your SAS session unless you terminate it with ODS TRACE OFF.

    My second suggestion is to a) direct your output to the LISTING destination and then b) use ODS TRACE ON/LISTING. That way your ODS table name information is written to the Output Window (or "Listing Destination") just before the output in the table. I've found this an easy way to learn both the table name of interest AND the contents of the table without having to flip back and forth between the LOG (where your ODS table name info is written by default) and the output tables themselves.

    Andrew Karp
    Sierra Data Science
    http://www.SierraDataScience.com

    • Rick Wicklin

      Great advice. I always do (1), but you are correct that I should have made it more explicity in my post. I have added ODS TRACE OFF after the example.

      I did not think of (2), but I love it! Thanks for the useful tip for when I'm too lazy to look at the doc.

  2. Pingback: ODS OUTPUT: Store any statistic created by any SAS procedure - The DO Loop

Leave A Reply

Back to Top