Remember Permutation/Combination Chapter from +2 days ? If {for i = 1 to 5} sum x(i) = 3 and x(i)'s are binary then there will be three 1's and two 0's. Let me reframe the problem in the following way - In how many ways three 1's and two 0's can be arranged in permutation so that 1's always come together ? We consider three 1's as a single unit(let's say =3) and proceed with the permutation. So it would be 3! total. [For the time being, lets forget as two 0's are actually the same, so total number of permutation would be 3!/2!. Actually I could not find out this option in SAS. Please update me if anybody gets it] proc plan;
factors Block=6 ordered B=3 of 3 perm;
ods output Plan=results;
run; This will produce the following output- Block B1 B2 B3
1 1 2 3
2 1 3 2
3 2 1 3
4 2 3 1
5 3 1 2
6 3 2 1 Once you replace the value of B1/B2/B3 as follows you will find few duplication in blocks. data results(keep=Digit);
set results;
format Digit1 Digit2 Digit3 $5.;
if B1 in (1,2) then Digit1='0'; else Digit1 = '1-1-1';
if B2 in (1,2) then Digit2='0'; else Digit2 = '1-1-1';
if B3 in (1,2) then Digit3='0'; else Digit3 = '1-1-1';
Digit = CATX ("-", OF Digit1-Digit3);
run; Results - Digit
0-0-1-1-1
0-1-1-1-0
0-0-1-1-1
0-1-1-1-0
1-1-1-0-0
1-1-1-0-0 Dedupe it - proc sort data=results nodupkey; by Digit; run; And you get the desired results- Digit
0-0-1-1-1
0-1-1-1-0
1-1-1-0-0 Use substr function to create 5 column from the Digit column.

... View more