``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40``` ```* To rank a var1 based on equal distances between min and max value of var1. * (This code has not been tested when the minimum is negative). * rlevesque@videotron.ca. DATA LIST FREE /var1(F8). BEGIN DATA. 0 15 31 91 17 24 29 98 57 90 6 7 100 24 74 21 END DATA. LIST. COMPUTE dummy=1. AGGREGATE /OUTFILE='min_max.SAV' /BREAK=dummy /var1_min = MIN(var1) /var1_max = MAX(var1). MATCH FILES /FILE=* /TABLE='min_max.SAV' /BY dummy. *Lets say you want to separate values in 8 intervals. COMPUTE #delta=(var1_max - var1_min)/8. COMPUTE inter=MIN(TRUNC(var1/#delta)+1,8). EXECUTE. *A short technical note: *The intervals are closed on the left and opened on the right. *inter=1 when var1 is in the interval [var1_min, var1_min + 1*#delta) *inter=2 when var1 is in the interval [var1_min+1*delta, var1_min + 2*#delta) *... *inter=8 when var1 is in the interval [var1_min+7*delta, var1_min + 8*#delta) *inter=9 when var1= var1_max. *The purpose of the last COMPUTE is to force cases with var1=var1_max into the interval 8. In *other words inter =8 is for cases in the closed interval [var1_min+7*delta, var1_min + 8*#delta]. *One impecfect method to avoid this adjustment would be to define delta as follows: COMPUTE #delta=1.000001*(var1_max - var1_min)/8. ```
Related pages

...