SAS author’s tip: Wrangling specific statistical values from SAS output

0

This week’s author tip is from Jack Shostak’s new book SAS Programming in the Pharmaceutical Industry, Second Edition.

If you're interested in this week's free tip and want to learn more about the topic or book, visit our online catalog. You'll find a free book excerpt, example code and data, and more.

General Approach to Obtaining Statistics

The previous sections show you how to extract p-values for a commonly used set of statistical tests. This section describes a general step-by-step approach for getting your statistics from a SAS procedure into data sets for clinical trial table or graph reporting. Here are the steps to follow:

  1. Determine which statistics you need in your table by looking at the listing destination output of your statistical procedure.
  2. Check the SAS procedure syntax to see whether there is an output data set that will provide you with the statistical values that you need. The output data sets from the SAS procedures are usually easier to use than the ODS OUTPUT data sets.
  3. If you cannot find what you need in an output data set from the statistical procedure, use ODS OUTPUT to send your statistics to a data set. To determine the name of the data set object to output, perform an ODS TRACE on your SAS procedure like this:
ods trace on;
proc ...
run;
ods trace off;

Then go to your SAS log to see which “tables” or data sets the SAS procedure makes. Each block of text in your SAS listing output typically translates into a SAS data set in ODS. You can see what each table is called by looking at the “Output Added” blocks in your SAS log. These blocks look something like this:

Output Added:

-------------

Name:       ShortName

Label:      Dataset Label

Template:   3 level name

Path:       2 level name

-------------

4. “ShortName” from step 3 is what your ODS object, and, in this case, data set, is called. Simply wrap an ODS OUTPUT statement around your SAS procedure to create the needed data set:

ods output ShortName = yourdatasetname;
proc ...
run;
ods output close;

The statistics that you need are now in the data set called “yourdatasetname.”

Note that when you obtain statistics from an ODS output data set, the results that you see there may appear different from what you see in your ODS listing destination (LST file).  This is because a SAS procedure may round to a different precision in the ODS listing destination from the precision at which you present your ODS output statistics. The numbers in the data set are the same, but the way they are rounded may make the statistic appear different.

(The following excerpt is from SAS Press author Jack Shostak’s book, “SAS Programming in the Pharmaceutical Industry, Second Edition”. Copyright © 2014, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (Please note that results may vary depending on your version of SAS software.)

 

Share

About Author

Maggie Miller

Education and Training

+ Maggie Miller was formerly a communications specialist at SAS. You'll likely find her writing blogs, shooting videos and sharing it all on social media. She has nearly ten years of journalism experience that she brings to her writing to help you learn and grow with SAS. Follow on Twitter @maggiemiller0

Comments are closed.

Back to Top