BookmarkSubscribeRSS Feed
cneron
Calcite | Level 5

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

2 REPLIES 2
Shmuel
Garnet | Level 18

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.

mkeintz
PROC Star

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;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 7252 views
  • 2 likes
  • 3 in conversation