複数の変数の値のすべての順列を変化量の小さい順に生成します。
カテゴリ: | 組み合わせ |
data _null_; array x [4] $3 ('ant' 'bee' 'cat' 'dog'); n=dim(x); nfact=fact(n); do i=1 to nfact+1; change=allperm(i, of x[*]); put i 5. +2 change +2 x[*]; end; run;
1 0 ant bee cat dog 2 3 ant bee dog cat 3 2 ant dog bee cat 4 1 dog ant bee cat 5 3 dog ant cat bee 6 1 ant dog cat bee 7 2 ant cat dog bee 8 3 ant cat bee dog 9 1 cat ant bee dog 10 3 cat ant dog bee 11 2 cat dog ant bee 12 1 dog cat ant bee 13 3 dog cat bee ant 14 1 cat dog bee ant 15 2 cat bee dog ant 16 3 cat bee ant dog 17 1 bee cat ant dog 18 3 bee cat dog ant 19 2 bee dog cat ant 20 1 dog bee cat ant 21 3 dog bee ant cat 22 1 bee dog ant cat 23 2 bee ant dog cat 24 3 bee ant cat dog 25 -1 bee ant cat dog