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
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.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.