Generates all distinct permutations of the non-missing values of several variables in lexicographic order.
| Category: | Combinatorial |
specifies an integer variable that ranges from 1 to the number of permutations.
specifies either all numeric variables, or all character variables that have the same length. The values of these variables are permuted by LEXPERM.
| Requirement | Initialize these variables before you execute the LEXPERM function. |
data _null_;
array x[6] $1 ('X' 'Y' 'Z' ' ' 'Z' 'Y');
nfact=fact(dim(x));
put +3 nfact=;
do i=1 to nfact;
rc=lexperm(i, of x[*]);
put i 5. +2 rc= +2 x[*];
if rc<0 then leave;
end;
run; nfact=720
1 rc=1 X Y Y Z Z
2 rc=3 X Y Z Y Z
3 rc=4 X Y Z Z Y
4 rc=2 X Z Y Y Z
5 rc=4 X Z Y Z Y
6 rc=3 X Z Z Y Y
7 rc=1 Y X Y Z Z
8 rc=3 Y X Z Y Z
9 rc=4 Y X Z Z Y
10 rc=2 Y Y X Z Z
11 rc=3 Y Y Z X Z
12 rc=4 Y Y Z Z X
13 rc=2 Y Z X Y Z
14 rc=4 Y Z X Z Y
15 rc=3 Y Z Y X Z
16 rc=4 Y Z Y Z X
17 rc=3 Y Z Z X Y
18 rc=4 Y Z Z Y X
19 rc=1 Z X Y Y Z
20 rc=4 Z X Y Z Y
21 rc=3 Z X Z Y Y
22 rc=2 Z Y X Y Z
23 rc=4 Z Y X Z Y
24 rc=3 Z Y Y X Z
25 rc=4 Z Y Y Z X
26 rc=3 Z Y Z X Y
27 rc=4 Z Y Z Y X
28 rc=2 Z Z X Y Y
29 rc=3 Z Z Y X Y
30 rc=4 Z Z Y Y X
31 rc=-1 Z Z Y Y X