hi need quick help!
if i need to get the top% & bottom 10% by each group.
can you please give me some solution with example.
Thanks Inadvance
Mahendra
Here's one way, using PROC RANK -- tailor made for problems like this. The RANK procedure can assign ranks by decile (groups=10), so rank=0 is the lowest 10%, and rank=9 is the highest 10%. Here's an example with the CARS data.
proc sort
data=sashelp.cars
out=work.sortedcars
;
by origin;
run;
proc rank data = work.sortedcars
groups=10
ties=mean
out=top_bottom;
by origin;
var msrp;
ranks ranked_msrp ;
run;
title "top 10% in each group";
proc print data=top_bottom;
var origin make model msrp;
where ranked_msrp = 9;
by origin;
run;
title "bottom 10% in each group";
proc print data=top_bottom;
var origin make model msrp;
where ranked_msrp = 0;
by origin;
run;
Take a look at documentation on PROC RANK. You'll probably want to set the GROUPS=10 option.
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!
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.