DATA Step, Macro, Functions and more

Proc Means Output In Desired Format

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Proc Means Output In Desired Format

While running proc means, the output is as follows: 

Capture.PNG

But while outputting the dataset using Output= statement, the format is completely different (Only one row with all stats of variables as variable names).

How can i get the output dataset in the same above format? (Need other stats as NMiss & Percentiles etc.)


Accepted Solutions
Solution
‎03-07-2016 03:23 PM
SAS Super FREQ
Posts: 3,488

Re: Proc Means Output In Desired Format

[ Edited ]

Use the STACKODSOUTPUT option, which was introduced in SAS 9.3:

 

/* Use the STACKODSOUTPUT option to get output in a more natural shape */
proc means data=sashelp.cars StackODSOutput 
           N NMISS MEAN STD P25 MEDIAN P75; 
var mpg_city mpg_highway;
ods output summary=out;
run;
 
proc print data=out noobs;run;

 

View solution in original post


All Replies
Super User
Posts: 10,550

Re: Proc Means Output In Desired Format

Do you need the data or a report table? If you want a readable table in the form you are showing then using ODS to output the table output would be the easiest thing.

 

Or transpose the output set

 

 

 

Occasional Contributor
Posts: 8

Re: Proc Means Output In Desired Format

@ballardw: I need an output dataset in the same format as the report.(Variable Mean Min Max etc.)

 

Transposing the output has one row for each Statistic of the variable (Variable1_Mean, Variable1_Min etc.) but i want only one row for each variable and ststistics in columns (Same as report format).

Solution
‎03-07-2016 03:23 PM
SAS Super FREQ
Posts: 3,488

Re: Proc Means Output In Desired Format

[ Edited ]

Use the STACKODSOUTPUT option, which was introduced in SAS 9.3:

 

/* Use the STACKODSOUTPUT option to get output in a more natural shape */
proc means data=sashelp.cars StackODSOutput 
           N NMISS MEAN STD P25 MEDIAN P75; 
var mpg_city mpg_highway;
ods output summary=out;
run;
 
proc print data=out noobs;run;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 303 views
  • 3 likes
  • 3 in conversation