STACKODSOUTPUT – Analysis Ready Statistics in a Single Proc Means Step

 

Author: Ms. Amala Peter – Clinical SAS Programmer at Genpro

In Clinical Programming, it becomes necessary to apply Proc Means to multiple variables in a single step. The output dataset is most preferred when compared over the results viewer or output windows. Proc Means is a frequently used SAS procedure for creating datasets with variable statistics. The need for deriving statistic for multiple variables is a common situation that every statistical programmer face and is often not possible with the direct output statement in Proc Means. In such situations, the SAS ODS is of great help. Below we display different codes implementing Proc Means and their corresponding output datasets.

SAS Code

proc means data = sashelp.class n min max mean std median;

var height weight;

output out =Means1;

run;

Sample Output

In this case, the statistics names are generated as the values of the variable _STAT_ rather than variable names.  The default statistics generated include n, min, max, mean, and std. But median even when specified is not generated by this code.

SAS Code

proc means data = sashelp.class;

var height weight;

output out =Means2 n=n mean=mean std=std min = min max = max median = median;

run;

Sample Output

Here each statistic mentioned will create a new variable and median is also created in the output dataset. But when we investigate the output dataset, statistics are generated only for variable ‘height’ even when two variables are specified in var statement and the html output have statistics for each of these specified variables.  In such situations where we want statistics of multiple numeric variables, we can make use of the ODS.

SAS Code

proc means data = sashelp.class n mean median std STACKODSOUTPUT;

var height weight;

ods output Summary=Means;

run;

Sample Output

If we are not specifying the variables in the var statement, statistics will be produced for all numeric variables in the dataset. The stackodsoutput option allows the data set to resemble the default printed output from Proc Means. In this structure, the analysis variables are stacked in one column and there is a column for each statistic. Without this option, the output dataset will contain separate column for each analysis variable and statistic.

Sample Output

In Clinical programming, Proc Means dataset outputs are of great use for generating summary tables. ODS provides us with options like stackodsoutput, helpful in creating datasets more efficiently. Making use of the SAS options not only makes programming easier, but also helps dealing data in a more feasible way.

Wish to know more? Feel free to write to us at info@genproindia.com

You may also like:
SAS Index – Make Subsetting Quick

Author: Dinesh Motkar – Clinical SAS Programmer at Genpro As part of SAS programming, we often come across situations where we need to remove unwanted data or to locate specific rows from data. Performing this processing using where clause or statement along with index can...

Read More
Introduction to Linear Mixed Model

Introduction to Linear Mixed Model   Author: Anoop Jose – Clinical SAS Programmer at Genpro Research In clinical trials, usually, we take multiple measurements from a subject at different time points. In the case of repeated measures or longitudinal data, multiple observations are collected from...

Read More
Clinical Data and Wearable Device: Future of Data Capturing

Clinical Data and Wearable Device: Future of Data Capturing   Author: Mr. Vinu C Raju – Clinical Statistical Programmer at Genpro Have you ever wondered how your social networking app is suggesting a friend request for a person you met yesterday in a get together? ...

Read More
Our Products

Voody

Moss

Subx

close