Generates all combinations of the values of n variables taken k at a time in a minimal change order.
Category: | Combinatorial |
specifies an integer variable that is assigned from 1 to the number of combinations in a loop.
specifies an integer constant, variable, or expression between 1 and n, inclusive, that specifies the number of items in each combination.
specifies either all numeric variables, or all character variables that have the same length. The values of these variables are permuted.
Restriction | Specify no more than 33 items. If you need to find combinations of more than 33 items, use the CALL ALLCOMBI routine. |
Requirement | Initialize these variables before calling the ALLCOMB routine. |
Tip | After calling the ALLCOMB routine, the first k variables contain the values in one combination. |
%macro test; %let x1=ant; %let x2=-.1234; %let x3=1e10; %let x4=hippopotamus; %let x5=zebra; %let k=2; %let ncomb=%sysfunc(comb(5,&k)); %do j=1 %to &ncomb+1; %syscall allcomb(j, k, x1, x2, x3, x4, x5); %let jfmt=%qsysfunc(putn(&j,5.)); %let pad=%qsysfunc(repeat(%str(),30-%length(&x1 &x2))); %put &jfmt: &x1 &x2 &pad sysinfo=&sysinfo; %end; %mend; %test
1: ant -0.1234 sysinfo=0 2: ant zebra sysinfo=2 3: ant hippopotamus sysinfo=2 4: ant 10000000000 sysinfo=2 5: -0.1234 10000000000 sysinfo=1 6: -0.1234 zebra sysinfo=2 7: -0.1234 hippopotamus sysinfo=2 8: 10000000000 hippopotamus sysinfo=1 9: 10000000000 zebra sysinfo=2 10: hippopotamus zebra sysinfo=1 11: hippopotamus zebra sysinfo=-1