%let m = 5;
data ex;
   do i = 1 to &m;
      do j = i + 1 to &m;
         output;
      end;
   end;
run;

proc print noobs;
run;

data mat;
  input x1-x3;
  datalines;
1 1 1
2 3 .
2 4 .
3 4 .
2 3 4
5 5 .
6 7 .
8 . .
;

%macro sumres;
   allone = 0; oneone = 0; alltwo = 0;
   do k = 1 to 22;
      if      (x[k] = 1 & x[k+22] = 1) then allone = allone + 1;
      else if (x[k] = 1 & x[k+22] = 2) |
              (x[k] = 2 & x[k+22] = 1) then oneone = oneone + 1;
      else if (x[k] = 2 & x[k+22] = 2) then alltwo = alltwo + 1;
   end;

   bad = 100 # (^(5 <= allone & allone <= 9)) # abs(allone - 7) +
          10 # (^(5 <= oneone & oneone <= 9)) # abs(oneone - 7) +
               (^(5 <= alltwo & alltwo <= 9)) # abs(alltwo - 7);
%mend;

%mktex(3 ** 50,                     /* 50 three-level factors               */
       n=135,                       /* 135 runs                             */
       restrictions=sumres,         /* name of restrictions macro           */
       seed=289,                    /* random number seed                   */
       options=resrep               /* restrictions report                  */
               quickr               /* very quick run with random init      */
               nox)                 /* suppresses x1, x2, x3 ... creation   */

%mktkey(x1-x50)

data key;
   input (x1-x25) ($);
   datalines;
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13
x14 x15 x16 x17 x18 x19 x20 x21 x22                  x45 x46 x47
x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34
x35 x36 x37 x38 x39 x40 x41 x42 x43 x44              x48 x49 x50
;

%mktroll(design=design, key=key, out=chdes)

proc print data=chdes;
   by set;
   id set;
   where set le 2 or set ge 134;
run;

%mktruns(4 2  4 2  4 2)

%mktex(4 2  4 2  4 2, n=16, seed=17)

proc print data=Design;
run;

%macro res;
   if x1 = x3 & x1 = x5 then bad = 1;
   if x2 = x4 & x2 = x6 then bad = bad + 1;
%mend;

%mktex(4 2  4 2  4 2, n=16, restrictions=res, seed=17)

proc print data=Design;
run;