In Access I'd take the column I'm looking to get the data from select it. Go to its properties, go to Top Values, and I'd put in the percentage I wanted of the current list. For instance a Cost list. 1000 members, I only want to know the top 2% of cost of my members. I place 2% in and the list shows the top 2% of cost of my members.
How can I do this in SAS?
I'd just use proc rank
.
groups=100
creates 100 ranked groups based on the variable var1
specified in the var
statement. The ranks
statement puts the groups into a new variable percentile
.
proc rank data=have out=have_ranked groups=100;
ranks percentile;
var var1;
run;
data want;
set have_ranked;
where percentile ge 98;
run;
You could also use proc univariate to get cutoff point for top 2%, then select obs you need. Something like:
proc univariate data=sashelp.class;
var weight;
output out=cutoff pctlpts=98 pctlpre=weight;
run;
data class;
set sashelp.class;
if _n_=1 then set cutoff;
if weight>=weight98 then output;
run;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With