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.
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.