[code:3bsg1h19]proc format;
invalue newfmt
'a'=1
'c'=2
'd'=3
'b'=4;
run;
data ex;
input ch $ x1-x2;
cards;
a 1 3
aa 2 0
ab 2 1
ac 2 2
ad 2 3
b 2 5
c 3 5
d 4 6
;
data exv/view=exv;
set ex;
newch=input(ch, newfmt.); /* define your ordering in newfmt. */
run;
proc sort data=exv out=ex2(drop=newch) sortsize=max;
by newch;
run;[/code:3bsg1h19]