You must have an old version of IML that does not have EXPANDGRID, in any case it will give permutations rather than combinations.
If you prefer an IML solution, then your original idea of a loop over the allcomb function is sound, the tricky part of the problem is working out how many combinations of each size there are, and where to place them in the final matrix c. Here is my suggestion for achieving this:
proc iml;
n = 5;
maxk = 3;
nc = comb( n, 1:maxk ); /* ncomb for each size k */
c = j(sum(nc), maxk, .); /* matrix to hold everything */
r2 = cusum( nc ); /* last row in c of size k */
r1 = r2 - nc + 1; /* first row in c of size k */
do k = 1 to maxk; /* fill c with combinations */
c [ r1[k]:r2[k], 1:k] = allcomb(n, k);
end;
print c;
quit;
... View more