Incomplete Block Design

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: FACTEX7B                                            */
/*   TITLE: Incomplete Block Design                             */
/* PRODUCT: QC                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Design of Experiments, Factorial Designs,           */
/*   PROCS: FACTEX PLAN                                         */
/*    DATA:                                                     */
/*                                                              */
/*     REF: SAS/QC Software:  Usage and Reference, Version 6,   */
/*          First Edition, Volume 1 and Volume 2                */
/*    MISC:                                                     */
/*                                                              */
/****************************************************************/

proc factex;
   factors x1-x5 / nlev=4;
   size design=16;
   model r=3;
   output out=a;
run;

data b;
   keep Rep Block Plot t;
   array x{5} x1-x5;
   do Rep = 1 to 5;
      do Block = 1 to 4;
         Plot = 0;
         do n = 1 to 16;
            set a point=n;
            if (x{rep}=Block-1) then do;
               t = n;
               Plot = Plot + 1;
               output;
            end;
         end;
      end;
   end;
   stop;
run;

data _null_;
   array s{4} s1-s4;
   file print;
   n = 1;
   do r = 1 to 5;
      put "Replication " r 1.0 ":";
      do b = 1 to 4;
         do p = 1 to 4;
            set b point=n;
            s{Plot} = t;
            n = n+1;
         end;
         put "    Block " b 1.0 ":" (s1-s4) (3.0);
      end;
      put;
   end;
   stop;
run;

proc plan seed=54321;
   factors Rep=5 Block=4 Plot=4 / noprint;
   output data=b out=c;
run;
proc sort;
   by Rep Block Plot;
run;

data _null_;
   array s{4} s1-s4;
   file print;
   n = 1;
   do r = 1 to 5;
      put "Replication " r 1.0 ":";
      do b = 1 to 4;
         do p = 1 to 4;
            set c point=n;
            s{Plot} = t;
            n = n+1;
         end;
         put "    Block " b 1.0 ":" (s1-s4) (3.0);
      end;
      put;
   end;
   stop;
run;