Monday, September 22, 2008

Partial sorting

SAS can also do the partial sorting like Excel does. Since SAS deals with observation as basic unit, subsetting and merging is necessary before a partial soring by Proc Sort.

data one;
input @1 var1 1. @3 var2 $1. @5 var3 $1. @7 var4 1. @9 var5 $1.;
cards;
1 Y A 7 Z
3 J A 6 T
2 E A 5 S
7 Z A 4 Q
4 Q B 3 J
6 T B 2 E
5 S B 1 Y
;run;

proc sort data=one out=one_s(drop=var4 var5);
by descending var1;
run;

data two;
set one_s;
set one(keep=var4 var5);
run;