Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Values in a column that are in a %

Tags:

percentile

sas

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?

like image 842
Xodiak Avatar asked Mar 17 '23 04:03

Xodiak


2 Answers

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;
like image 179
DWal Avatar answered Apr 29 '23 20:04

DWal


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;
like image 34
Shenglin Chen Avatar answered Apr 29 '23 18:04

Shenglin Chen