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.
在Access中我会选择我想要从中选择数据的列。转到它的属性,转到Top Values,然后我输入我想要的当前列表的百分比。例如,成本列表。 1000名成员,我只想知道我的成员的前2%的成本。我将2%放入,列表显示了我的会员成本的前2%。
How can I do this in SAS?
我怎么能在SAS中这样做?
2 个解决方案
#1
I'd just use proc rank
.
我只是使用proc等级。
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
.
groups = 100根据var语句中指定的变量var1创建100个排名组。 rank语句将组放入新的变量百分位数。
proc rank data=have out=have_ranked groups=100;
ranks percentile;
var var1;
run;
data want;
set have_ranked;
where percentile ge 98;
run;
#2
You could also use proc univariate to get cutoff point for top 2%, then select obs you need. Something like:
你也可以使用proc univariate来获得前2%的截止点,然后选择你需要的obs。就像是:
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;
#1
I'd just use proc rank
.
我只是使用proc等级。
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
.
groups = 100根据var语句中指定的变量var1创建100个排名组。 rank语句将组放入新的变量百分位数。
proc rank data=have out=have_ranked groups=100;
ranks percentile;
var var1;
run;
data want;
set have_ranked;
where percentile ge 98;
run;
#2
You could also use proc univariate to get cutoff point for top 2%, then select obs you need. Something like:
你也可以使用proc univariate来获得前2%的截止点,然后选择你需要的obs。就像是:
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;