Chapter Contents

Previous

Next
The RANK Procedure

Example 2: Ranking Values within BY Groups


Procedure features:
PROC RANK statement options:
DESCENDING
TIES=
BY statement
RANKS statement
VAR statement
Other features:
PRINT procedure

This example


Program

options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
data elect;
   input Candidate $ 1-11 District 13 Vote 15-18 Years 20;
   datalines;
Cardella    1 1689 8
Latham      1 1005 2
Smith       1 1406 0
Walker      1  846 0
Hinkley     2  912 0
Kreitemeyer 2 1198 0
Lundell     2 2447 6
Thrash      2  912 2
;
 Note about code
proc rank data=elect out=results ties=low descending;


 Note about code
   by district;
 Note about code
   var vote years;
   ranks VoteRank YearsRank;
run;
 Note about code
proc print data=results n;
   by district;
   title 'Results of City Council Election';
run; 


Output
In the second district, Hinkley and Thrash tied with 912 votes. They both receive a rank of 3 because TIES=LOW. [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.