Previous Page | Next Page

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

The following output 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;

Assignment of the Lowest Rank Value to the Lowest Variable Value

                                 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  

In the following output, 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.

This example shows how PROC RANK can do the following tasks:

For an explanation of the program that produces this report, see Ranking Values within BY Groups.

Assignment of the Lowest Rank Value to the Highest Variable Value within Each BY Group

                        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

Previous Page | Next Page | Top of Page