BookmarkSubscribeRSS Feed

Okay ODS, just give me what I want!

Started ‎11-17-2014 by
Modified ‎10-06-2015 by
Views 2,292

One of the most powerful but most misunderstood (and occasionally frustrating) features of coding in SAS is the ODS system. ODS, which stands for Output Delivery System, is the way that the SAS system allows users to render output in the form of graphs and tables. It is very powerful but often confusing, especially to those coming to SAS from other statistical computing languages. Here are two tips that I have learned in the past few years that might help you leverage the power of ODS. It has to do with which output is rendered. I found myself asking the question….

 

WHAT IF I DON’T WANT TO SEE SO MUCH OUTPUT! JUST GIVE ME THE TABLES I WANT?!

 

This is a natural question for those coming from other programming languages. Whether it is R, Stata or Matlab, the amount of information SAS provides to the user after a statistical model is impressive. Sometimes, it is also cumbersome. So how can you limit output?

First, let’s make sure you have the ODS system on which you can ensure by entering,

ods graphics on;

 

at the beginning of your sas program.

 

From here let’s try to run a simple regression using the familiar  REG procedure. Here is the output.

 

long_regression.png

 

Gosh that is a lot of information!

 

What if I really just want to look at the fit statistics or perhaps just the coefficient table? How do I do this?

The easy way is with creative use of the “ods select” statements within the PROC call. Here is an example of how to just ask for the coefficient table.single_table.png

Or perhaps I just want to see the parameter estimates and the residual plots. Notice I need to make two changes to the syntax. First I must ask for the plot to be produced (plots=residualplot) as well as I need to add that item to the ods select statement. Here is the result.

table_and_picture.png

 

So where can I find the name of these tables and graphics? Each table and graph in each PROC has a name. For a list of all the names you can go to the “Details” section for the documentation for each procedure. There are separate sections for “ODS Table Names” and “ODS Graphics”.  Here are the sections for the AUTOREG procedure (Tables, Graphics).

 

WHAT IF I WANT TO CREATE A DATASET FROM THE ODS TABLES I SELECT?

 

What if you want to save a specific ODS table to a data set? The “ODS OUTPUT” option allows for this. For example, if we want to save the above parameter estimates table as a sas dataset, you can add the “ODS OUTPUT PARAMETERESTIMATES=WORK.PARMS;” option to the PROC REG call. In this case, the file is saved in the WORK directory, but you can save it wherever you like.

 

table_and_select.png

 

These were just my suggestions. Do you have some of your own? Do you like using the ODS TRACE options?

Please share those in the comment section below so we all can become comfortable working with the powerful ODS options available to you.

Comments

I have used ODS TRACE. I prefer to have the information in the documentation: it is known to the PROC writers so they can tell us. If you use trace, you have to run the code an extra time just to discover what is already known. I view tracing as a debugging tool.

Hi ets_kps - I moved your document to the ODS and Base Reporting community- just wanted to let you know. Thanks for the great article

I want to be able to view ONLY the residual plots in my output using ods.

 

I am using proc glimmix, and created residual plots to check assumptions for a large data set. So I have 3 residual plots (original, log10, and ln) for each data point and I just want to streamline the comparison of plots between the 3.  I have tried using ods but can't seem to get the syntax just right.

 

 Any suggestions, please?

 

proc glimmix data=a plots=residualpanel ;
class blk cover tillage;
model y=cover|tillage/ddfm=satterth;
random blk blk*cover blk*cover*tillage;
lsmeans cover/ lines pdiff;
lsmeans tillage/ lines pdiff;
lsmeans cover*tillage/lines pdiff;
run;

 

 Hi @JohnKP, thanks for joining the communities and posting in here. Your best bet for a quick answer would be to post your question on the ODS and Base Reporting Community: https://communities.sas.com/t5/ODS-and-Base-Reporting/bd-p/ods_base_reporting More experts will see it there than in this old comment thread.

Version history
Last update:
‎10-06-2015 03:12 PM
Updated by:
Contributors

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags