1283℃

# SAS的Proc rank 的用法

proc rank 其实最主要的是掌握那几个选项，该proc 的整体语法结构如下：

proc rank <选项>;
var 变量;
ranks 新变量名字;
by 分组变量;
run;

proc rank data=sashelp.class out=result;
var height;
run;

proc rank data=sashelp.class out=result;
var height;
ranks r_height;
run;

proc rank data=sashelp.class out=result descending;
var height;
ranks r_height;
run;

4 2.5 2.5 1 也就是相同值得话，名次怎么排，就是把相同的值得名次相加作平均。4 5 5 5 6 排名次的结果应该是 1 3 3 3 5 这些明白 ？OK？ 继续

proc rank data=sashelp.class out=result descending;
var height;
ranks r_height;
run;
等价
proc rank data=sashelp.class out=result descending ties=mean;
var height;
ranks r_height;
run;

proc rank data=sashelp.class out=result descending ties=low;
var height;
ranks r_height;
run;

proc rank data=sashelp.class out=result descending ties=high;
var height;
ranks r_height;
run;

proc rank data=sashelp.class out=result descending ties=mean fraction;
var height;
ranks r_height;
run;

NPLUS1 这个选项类同于fraction，前者除以(总人数+1) k/(n+1)，后者处以(总人数) k/n

proc rank data=sashelp.class out=result descending ties=mean percent;
var height;
ranks r_height;
run;

proc rank data=sashelp.class out=result descending ties=mean fraction;
var height;
ranks r_height;
run;

proc rank data=sashelp.class out=result descending ties=mean groups=2;
var height;
ranks r_height;
run;
groups=是用来指定分成几组，这里不是随机分组，是按照顺序以后的分组，也就是说排好名次后按名次顺序分组。

• 在线沟通，请点我在线咨询

• 咨询热线：
13261671783
客服qq：
3285157825