Hi all SAS Users,
Today I try to use PROC rank in my project, due to the characteristic, I need to rank 100 groups per year per country. However, in this year in this country, there are only 13 observation, I am quite surprise that SAS can assign some numbers over there. Can I ask how SAS can assign these rank_ numbers?
The value of variable need to be ranked
amihud
0.0005088943
1.4387286E-6
5.767935E-6
5.3867482E-7
2.1144515E-6
4.2862647E-6
0.0001175097
8.5303028E-6
0.000117864
3.4827424E-6
0.0000313065
0.0000173605
8.5760194E-6
And the result is
rank_
92
14
42
7
21
35
78
50
85
28
71
64
57
How come SAS rank 92 or 42 while there are only 13 obs over there.
Warm regards,
P/S: I think it is quite a bit irrelevant but my code is as below
proc rank data=work.trim_price groups=100 out=temp;
by LOC year;
Comment LOC is country;
var amihud;
ranks rank_;
run;
Hi @Phil_NZ,
Because of the GROUPS= option the values of variable RANK_ aren't really ranks, but group numbers defined by the formula
floor(rank*k/(n+1))
where rank is the rank that you would obtain without the GROUPS= option, k is the value specified in the GROUPS= option and (since you use the default TIES=MEAN) n is the number of observations with nonmissing values of your analysis variable AMIHUD (see documentation).
So, in your example the ranks r = 1, 2, ..., 12, 13 are transformed into floor(r*100/14) = 7, 14, ..., 85, 92.
Hi @Phil_NZ,
Because of the GROUPS= option the values of variable RANK_ aren't really ranks, but group numbers defined by the formula
floor(rank*k/(n+1))
where rank is the rank that you would obtain without the GROUPS= option, k is the value specified in the GROUPS= option and (since you use the default TIES=MEAN) n is the number of observations with nonmissing values of your analysis variable AMIHUD (see documentation).
So, in your example the ranks r = 1, 2, ..., 12, 13 are transformed into floor(r*100/14) = 7, 14, ..., 85, 92.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.