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.
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;
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 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.
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
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.