ANOM Charts Using LIMITS= Data Set

/********************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                     */
/*                                                                  */
/*    NAME: ANMXEX4                                                 */
/*   TITLE: ANOM Charts Using LIMITS= Data Set                      */
/* PRODUCT: QC                                                      */
/*  SYSTEM: ALL                                                     */
/*    KEYS: ANOM Charts, Means Charts, XCHART, Two Factor, LIMITS=  */
/*   PROCS: ANOM                                                    */
/*    DATA:                                                         */
/*                                                                  */
/* SUPPORT: saswgr                                                  */
/*     REF: PROC ANOM, XCHART Statement, Example 4                  */
/*                                                                  */
/********************************************************************/

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
;


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;

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

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;

title "Parameters for ANOM for Effect of Position";
proc print data=ANOMParms noobs;
run;

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

data ANOMParmsB;
   keep _var_ _group_ _alpha_ _mean_;
      length _var_ _group_ $ 14;
   set MyFit (rename=(Dependent=_var_ DepMean  =_mean_));
      _group_ = 'depth';
      _alpha_ = 0.05;
run;
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;
run;
proc sort data=Cleaning;
by depth;
run;

proc print data=ANOMParmsB;
run;