Comparing Univariate and Multivariate Control Charts

/*****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                  */
/*                                                               */
/*    NAME: MVPMNEX3                                             */
/*   TITLE: Comparing Univariate and Multivariate Control Charts */
/* PRODUCT: QC                                                   */
/*  SYSTEM: ALL                                                  */
/*    KEYS: SERIES statement                                     */
/*   PROCS: MVPMONITOR                                           */
/*    DATA:                                                      */
/*                                                               */
/* SUPPORT: saswgr                                               */
/*     REF: PROC MVPMONITOR, Example 3                           */
/*                                                               */
/*****************************************************************/

proc iml;
   Mean = {0,0,0};
   Cor = {1.0 0.8 0.8,
          0.8 1.0 0.8,
          0.8 0.8 1.0};
   StdDevs = {2 2 2};
   D = diag(StdDevs);
   Cov = D*Cor*D; /* covariance matrix */
   NumSamples = 30;
   call randseed(123321);  /* set seed for the RandNormal module */
   X = RandNormal(NumSamples, Mean, Cov);
   varnames = { x1 x2 x3};
   create mvpStable from X [colname = varnames];
   append from X;
   quit;
run;
data mvpStable;
   set mvpStable;
   hour=_n_;
run;

proc iml;
   Mean = {0,0,0};
   Cor = { 1.0 -0.8  0.8,
          -0.8  1.0 -0.8,
           0.8 -0.8  1.0};
   StdDevs = {2 2 2};
   D = diag(StdDevs);
   Cov = D*Cor*D; /* covariance matrix */
   NumSamples = 5;
   call randseed(123321);  /* set seed for the RandNormal module */
   X = RandNormal(NumSamples, Mean, Cov);
   varnames = { x1 x2 x3};
   create mvpOOC from X [colname = varnames];
   append from X;
   quit;
run;
data mvpOOC;
   set mvpStable mvpOOC;
   hour=_n_;
run;

proc mvpmodel data=mvpStable ncomp=1 plots=none out=scores
              outloadings=loadings;
   var x1 x2 x3;
run;

proc mvpmonitor data=mvpOOC loadings=loadings;
   time hour;
   tsquarechart;
   spechart;
run;

proc shewhart data=mvpOOC;
   irchart (x1 x2 x3) * hour / markers nochart2;
run;