Produces ranks, from the values in a variate, allowing for ties (J.B. van Biezen & C.J.F. ter Braak).
Option
OMIT = string token |
Whether units excluded by a restriction on the DATA variate should be omitted from the RANKS variate (restricted); default *, i.e. the units are not omitted, and their values are left unchanged |
|---|
Parameters
DATA = variates |
Variate containing values to be ranked |
|---|---|
RANKS = variates |
Variate to save vector of ranks |
TIESIZE = variates |
Variate to save the sizes of ties |
Description
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).
The 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 OMIT=restricted, the RANKS variate is compressed to omit the excluded units; this setting is used particularly by the nonparametric procedures.
Option: OMIT.
Parameters: DATA, RANKS, TIESIZE.
Method
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 SORT.
Action with RESTRICT
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 DATA variate.
See also
Procedure: SORT.
Commands for: Calculations and manipulation.
Example
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