Chapter 41: The RANK Procedure


Overview: RANK Procedure

What Does the RANK Procedure Do?

The RANK procedure computes ranks for one or more numeric variables across the observations of a SAS data set and outputs the ranks to a new SAS data set. PROC RANK by itself produces no printed output.

Ranking Data

Output 41.1 shows the results of ranking the values of one variable with a simple PROC RANK step. In this example, the new ranking variable shows the order of finish of five golfers over a four-day competition. The player with the lowest number of strokes finishes in first place. The following statements produce the output:

 proc rank data=golf out=rankings;     var strokes;     ranks Finish;  run;  proc print data=rankings;  run; 
Output 41.1: Assignment of the Lowest Rank Value to the Lowest Variable Value
start example
 The SAS System                    1  Obs    Player    Strokes     Finish   1     Jack        279          2   2     Jerry       283          3   3     Mike        274          1   4     Randy       296          4   5     Tito        302          5 
end example
 

In Output 41.2, the candidates for city council are ranked by district according to the number of votes that they received in the election and according to the number of years that they have served in office.

Output 41.2: Assignment of the Lowest Rank Value to the Highest Variable Value within Each BY Group
start example
 Results of City Council Election                       1  ---------------------------------- District=1 ----------------------------------                                                     Vote    Years                 Obs    Candidate    Vote    Years    Rank     Rank                  1     Cardella     1689      8        1       1                  2     Latham       1005      2        3       2                  3     Smith        1406      0        2       3                  4     Walker        846      0        4       3                                       N = 4  ---------------------------------- District=2 ----------------------------------                                                      Vote    Years                 Obs    Candidate     Vote    Years    Rank     Rank                  5     Hinkley        912      0        3       3                  6     Kreitemeyer   1198      0        2       3                  7     Lundell       2447      6        1       1                  8     Thrash         912      2        3       2                                       N = 4 
end example
 

This example shows how PROC RANK can

  • reverse the order of the rankings so that the highest value receives the rank of 1, the next highest value receives the rank of 2, and so on

  • rank the observations separately by values of multiple variables

  • rank the observations within BY groups

  • handle tied values.

For an explanation of the program that produces this report, see Example 2 on page 839.




Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net