DATA Step, Macro, Functions and more

Changing order in PROC MEANS

Reply
Occasional Learner
Posts: 1

Changing order in PROC MEANS

I was wondering if there was a way to change the order in the variable analysis. Proc means automatically displays the variable analysis in alphabetical order, but is it possible to display the variable from highest to lowest mean or to only display the highest mean. 

 

thanks

Trusted Advisor
Posts: 1,837

Re: Changing order in PROC MEANS

Use the OUTPUT option of PROC MEANS to get the results in a sas dataset,

then use PROC PRINT or PROC REPORT to get the report with any desired order of variables.

Trusted Advisor
Posts: 1,346

Re: Changing order in PROC MEANS

proc means has a STACKODSOUTPUT, that works in combination with the ODS OUTPUT statement.  The output statement would ordinarily generate extra columns in the output dataset when you add vars to be analyzed.  But you actually want rows added for each analysis variable.  That what the STACKODSOUTPUT paramenter does:

 

ods listing  close;
proc means data=sashelp.class stackodsoutput;
  var height weight;
  ods output summary=mydata;
run;
ods listing;

proc sort data=mydata; 
  by descending mean;
run;
proc print data=mydata;run;
Ask a Question
Discussion stats
  • 2 replies
  • 208 views
  • 1 like
  • 3 in conversation