Produces ranks, from the values in a variate, allowing for ties (J.B. van Biezen & C.J.F. ter Braak).
||Whether units excluded by a restriction on the
||Variate containing values to be ranked|
||Variate to save vector of ranks|
||Variate to save the sizes of ties|
RANK calculates ranks of the values in a variate, allowing for ties. The variate must be specified by the
DATA parameter, and the ranks saved using the
RANKS parameter. The input variates in the parameter
DATA must each have at least one non-missing value. Missing values in the
DATA variates give corresponding missing values in the
RANKS variates. The
TIESIZE parameter can save the number of times each value occurs (starting with the lowest value).
OMIT option controls whether the
RANKS variate omits units that are excluded by a restriction on the
DATA variate. By default, the values in these units are left unchanged. However, if
RANKS variate is compressed to omit the excluded units; this setting is used particularly by the nonparametric procedures.
The procedure uses the
SORT directive to discover the number of distinct values in the input variate, and then uses
TABULATE to obtain the number of times each value occurs – i.e. the size of ties. The tie-corrected rank numbers are then calculated. From these, the vector of ranks is obtained by modifying the levels of the factor that resulted from the first
The variates in
DATA can be restricted, and in different ways.
RANK operates on the restricted set only. If
OMIT=restricted, the length of
RANKS will be the size of the restricted set of the
DATA variate. If
OMIT is unset, the
RANKS variate is of the same length as the
Commands for: Calculations and manipulation.
CAPTION 'RANK example'; STYLE=meta VARIATE [VALUES= 10,20...50,50,50] y RANK y;Ranky PRINT y,Ranky; DECIMALS=1 " Variate y1 is unrestricted. Variates y2 and y3 are restricted in different ways. The unrestricted values of these variates are ranked " VARIATE [VALUES=2,-2,-4,2,1,*,-2,-2,0,*] y1,y2,y3 RESTRICT y2; CONDITION=y1.GT.0 RESTRICT y3; CONDITION=y1.LT.-3 RANK [OMIT=restricted] DATA=y1,y2,y3; RANKS=r1,r2,r3 PRINT y1,r1 & y2,r2 & y3,r3 RANK DATA=y1,y2,y3; RANKS=R1,R2,R3; TIESIZE=*,t2,t3 PRINT y1,R1,R2,R3 & t2,t3