Procedure features: |
PROC RANK statement option:
|
BY statement |
VAR statement |
|
Other features: |
PRINT procedure |
SORT procedure |
|
This example performs the following
actions:
-
partitions observations into groups on the basis of values of
two input variables
-
groups observations separately within BY groups
-
replaces the original variable values with the group
values
|
options nodate pageno=1 linesize=80 pagesize=60; |
|
data swim;
input Name $ 1-7 Gender $ 9 Back 11-14 Free 16-19;
datalines;
Andrea F 28.6 30.3
Carole F 32.9 24.0
Clayton M 27.0 21.9
Curtis M 29.0 22.6
Doug M 27.3 22.4
Ellen F 27.8 27.0
Jan F 31.3 31.2
Jimmy M 26.3 22.5
Karin F 34.6 26.2
Mick M 29.0 25.4
Richard M 29.7 30.2
Sam M 27.2 24.1
Susan F 35.1 36.1
; |
|
proc sort data=swim out=pairs;
by gender;
run; |
|
proc rank data=pairs out=rankpair groups=3;
|
|
by gender; |
|
var back free;
run; |
|
proc print data=rankpair n;
by gender;
title 'Pairings of Swimmers for Backstroke and Freestyle';
run; |
|
Pairings of Swimmers for Backstroke and Freestyle 1
----------------------------------- Gender=F -----------------------------------
Obs Name Back Free
1 Andrea 0 1
2 Carole 1 0
3 Ellen 0 1
4 Jan 1 2
5 Karin 2 0
6 Susan 2 2
N = 6
----------------------------------- Gender=M -----------------------------------
Obs Name Back Free
7 Clayton 0 0
8 Curtis 2 1
9 Doug 1 0
10 Jimmy 0 1
11 Mick 2 2
12 Richard 2 2
13 Sam 1 1
N = 7
| |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.