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;
... View more