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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: