|
Kevin,
Two possible solutions:
1. Split up your token in variables, put these variables into an array and
sort the array. Then glue the sorted vars. For a quicksort implementation
see Paul Dorfman's www2.sas.com/proceedings/sugi26/p096-26.pdf
2. Split up the token in observations. Sort the dataset and then put it
back together. See code below.
data token;
input token $ 1-20;
datalines;
B+C+A
D+A
B
run;
data token2 (keep=id tok);
set token;
length tok $ 1;
id = _N_; * IDENTIFY THE SPLITTED TOKEN;
do i=1 to (length(token)+1)/2;
tok = substr(token, 2*i-1, 1);
output;
end;
run;
proc sort data=token2;
by id tok;
run;
data token3 (keep=token);
set token2;
by id tok;
length token $ 20;
retain token;
if first.id then token = tok;
else token = catx("+", token, tok);
if last.id then output;
run;
Hth,
Eric
|