Combined ANOM Charts Using LIMITS= Data Set

 /********************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                     */
 /*                                                                  */
 /*    NAME: ANMEX5                                                  */
 /*   TITLE: Combined ANOM Charts Using LIMITS= Data Set             */
 /* PRODUCT: QC                                                      */
 /*  SYSTEM: ALL                                                     */
 /*    KEYS: ANOM Charts, XCHART, Two Factor, Combined, LIMITS=      */
 /*   PROCS: ANOM                                                    */
 /*    DATA:                                                         */
 /*                                                                  */
 /*     REF: SAS/QC Software:  The ANOM Procedure                    */
 /*                                                                  */
 /********************************************************************/

 options nodate nostimer nonumber source2 ls=76 ps=80;


 /****************************************************************/

/*** Combined ANOM Charts Using LIMITS= Data Set ********/

data cleaning;
   do position = 1 to 5;
      do depth = 1 to 3;
         do rep = 1 to 2;
            input concentration @@;
            output;
         end;
      end;
   end;
   datalines;
   15 16 15 14 19 5
   15 16 14 14 0  8
   19 15 16 16 11 8
   18 16 19 15 8  14
   15 12 19 15 8  11
   ;
run;

/*** Saving Results from GLM for a Two-Way Classification ***/

 ods select FitStatistics ModelANOVA OverAllANOVA;
   ods output FitStatistics = MyFit
              ModelANOVA    = MyLimits
              OverAllANOVA  = MyOverAll;

   proc glm data=cleaning;
      class position depth;
      model concentration = position depth position*depth;
   run;


/*** Creating LIMITS= Data Set ANOMParms - Factor 1 (Position) ********/

data ANOMParms;
   keep _var_ _type_ _group_ _alpha_ _mean_;
      length _var_ _group_ $ 14;
   set MyFit (rename=(Dependent=_var_ DepMean  =_mean_));
      _type_ = 'estimate';
      _group_ = 'position';
      _alpha_ = 0.05;

data ANOMParms;
   merge ANOMParms
         MyLimits (where=(source='position')
                   keep = source DF);
                   _limitk_ = DF+1;
   drop source DF;
   merge MyOverAll (where=(source='Error')
            keep = source df ms
            rename=( df = _dfe_ ms = _mse_));
   drop source;
   merge MyOverAll (where=(source='Corrected Total')
                    keep = source DF);
                        _limitn_ = (DF+1)/_limitk_;
   drop source DF;
run;



/*** Creating Data Set PosTable - Factor 1 (Position) Effect ********/

 title "ANOM for Effect of Position";
   proc anom data=cleaning limits=ANOMParms;
      xchart concentration * position /outtable = postable;
      label position      = 'Position'
            concentration = 'Mean of Concentration';
   run;



/*** Creating LIMITS= Data Set ANOMParmsB - Factor 2 (Depth) ********/

data ANOMParmsB;
   keep _var_ _type_ _group_ _alpha_ _mean_;
      length _var_ _group_ $ 14;
   set MyFit (rename=(Dependent=_var_ DepMean  =_mean_));
      _type_ = 'estimate';
      _group_ = 'depth';
      _alpha_ = 0.05;

data ANOMParmsB;
   merge ANOMParmsB
         MyLimits (where=(source='depth')
                   keep = source DF);
                   _limitk_ = DF+1;
   drop source DF;
   merge MyOverAll (where=(source='Error')
            keep = source df ms
            rename=( df = _dfe_ ms = _mse_));
   drop source;
   merge MyOverAll (where=(source='Corrected Total')
                    keep = source DF);
                        _limitn_ = (DF+1)/_limitk_;
   drop source DF;

proc sort data=cleaning;
by depth;
run;



/*** Creating Data Set DepTable - Factor 2 (Depth) Effect ********/

   title "ANOM for Effect of Depth";
   proc anom data=cleaning limits=ANOMParmsB;
      xchart concentration * depth /outtable = deptable;
      label position      = 'Depth'
            concentration = 'Mean of Concentration';
   run;


/*** Creating Data Set SumTable -  Combined Factors ********/

data postable; set postable;
      length group factor $8;
      group  = cat(TRIM('Pos'),position);
      factor = 'Position';

data deptable; set deptable;
      length group factor $8;
      group  = cat(TRIM('depth'),depth);
      factor = 'Depth';

data sumtable;
    set postable deptable;
run;

 /*** Printing Data Set SumTable ********/

   title "Parameters for ANOM for Effect of Group";
   proc print data=sumtable;
   run;


 /*** Combined ANOM Charts Using Data Set SumTable ********/

   title "ANOM for Effect of Group";
   proc anom table=sumtable;
      xchart concentration * group (factor) / BLOCKPOS = 3;
      label group  = 'Group'
            _SUBX_ = 'Mean of Concentration';
   run;

 /****************************************************************/


 goptions reset=all;