Hi All,
I need to sort my output in the descending order of mean. Please help.
data average;
set sashelp.cars (KEEP = MAKE MODEL MSRP);
run;
proc means data = average mean nway nonobs;
class make;
var msrp;
run;
Easy to do with proc sql:
proc sql;
select make,mean(msrp) as mean format=dollar7.
from sashelp.cars
group by make
order by mean descending
;
quit;
HTH,
Art, CEO, AnalystFinder.com
Hello,
Thanks for the reply. But, I wanted to know if there is a way to do it using PROC MEANS descend /descending. Is it not allowed while using class?
Not that I'm aware of. AFAIK, all of the order by options are related to the class or by values or their frequency or formatted values.
Art, CEO, AnalystFinder.com
Since you want "I need to sort my output in the descending order of mean" then create an output data set and sort that;
proc summary data=SASHelp.cars nway;
class make;
var msrp;
output out = average (drop = _type_ _freq_) mean=;
run;
proc sort data=average;
by descending msrp;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.