Use the FACT function to determine the number of permutations possible, then generate all permutations of said variables with CALL ALLPERM.
Note: CALL ALLPERM and CATS function are new in SAS 9.0.data test;
drop i perms;
array x (3) $3 ('a' 'b' 'c');
/* create a new variable of the concatenated results */
length new $3;
perms=fact(3);
do i=1 to perms;
call allperm(i, of x(*));
new= cats(of x(*));
output;
end;
run;
proc print;
run;
output
Obs x1 x2 x3 new
1 a b c abc
2 a c b acb
3 c a b cab
4 c b a cba
5 b c a bca
6 b a c bac
No comments:
Post a Comment
I love to hear from you! Leave a comment.
If your question is unrelated to this article, please use my Facebook page.