SAS

sas program that will return the string sorted by the letters in the numbers.

The smallest sas program that will return the string sorted by the letters in the numbers.

“321j43 u43214 65n34 7647a 24i5 45d664”;


Output:
“7647a 45d664 24i5 321j43 65n34 u43214”

 

data k;
length before_sort after_sort $40;
before_sort=”321j43 u43214 65n34 7647a 24i5 45d664″;
array a(6) $ 6 _temporary_;
do i=1 to countw(before_sort);
a{i}=cats(compress(scan(before_sort, i, ” “), , ‘ka’), scan(before_sort, i,
” “));
end;
call sortc(of a(*));

do i=1 to countw(before_sort);
after_sort=catx(‘ ‘, after_sort, substr(a{i}, 2));
end;
drop i;
run;

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts