Resources

Zone control chart

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: SHWZONE                                             */
 /*   TITLE: Zone control chart                                  */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: Shewhart Charts, Zone Control Charts,               */
 /*   PROCS: SHEWHART                                            */
 /*    DATA:                                                     */
 /*                                                              */
 /*     REF: Davis, R. B.; Homer, A.; and Woodall, W. H. (1990). */
 /*          "Performance of the Zone Control Chart."            */
 /*          Communications in Statistics-Theory and Methods 19, */
 /*          pp. 1581-1587                                       */
 /*                                                              */
 /****************************************************************/
options ps=60 ls=80 nodate;

data one;
   drop   i;
   retain subgrp;
   input  subgrp @;
   do i=1 to 5;
      input  x @@;
      output;
      end;
   cards;
    1   99.8   99.6   99.0   99.1  100.3
    2  102.0   93.9  103.2  102.3  100.7
    3   94.2  101.8   97.4  106.8  100.1
    4  103.9  102.4  101.2  103.4  102.9
    5  100.7  102.5   95.9  102.0  105.9
    6  107.4   95.5   93.8   94.5   95.5
    7  101.5   95.5  102.0   99.9   98.2
    8   96.9   96.8   97.9   97.9   97.8
    9   95.8  102.3   96.9  106.5  101.6
   10   94.3   98.6  108.2  101.2   94.0
   11   93.2  102.4   98.1   90.3  101.2
   12  100.8   95.9   95.3   99.2  105.7
   13   99.1  101.6  105.2  103.2   96.6
   14  101.0  104.2   96.8  106.1   97.8
   15   99.7   98.1   99.7  104.2  101.3
   16  102.8   93.0   96.4  103.0  100.3
   17   98.4   97.4  102.3   99.8   97.7
   18   93.0   95.6   98.5  102.6  104.3
   19  102.5  100.8   94.9  101.4   99.1
   20   99.6  104.0   98.4  107.6  105.8
   21  102.0   98.7   97.6   98.2  102.6
   22  109.2  104.2   97.4   96.9  104.9
   23   90.4   93.4   96.6   96.3   90.2
   24  103.1  102.5  106.8  101.4  101.3
   25   98.9  104.9  103.8  100.2  102.7
   ;

proc shewhart data=one;
   xchart x*subgrp/nochart
                   outtable=table
                   stddev
                   outlimits=limits(keep=_stddev_);
   run;

data zones;
   set table;
   retain zp3 zp2 zp1 z00 zm1 zm2 zm3;
   drop   zp3 zp2 zp1 z00 zm1 zm2 zm3 _stddev_ side;

   if _n_ = 1 then do;
      set limits;
      zp3 = _mean_ + 3 * _stddev_ / sqrt( _limitn_ );
      zp2 = _mean_ + 2 * _stddev_ / sqrt( _limitn_ );
      zp1 = _mean_ + 1 * _stddev_ / sqrt( _limitn_ );
      z00 = _mean_;
      zm1 = _mean_ - 1 * _stddev_ / sqrt( _limitn_ );
      zm2 = _mean_ - 2 * _stddev_ / sqrt( _limitn_ );
      zm3 = _mean_ - 3 * _stddev_ / sqrt( _limitn_ );
      end;

   if _subx_ - _mean_ > 0 then
       side =  1;
   else
       side = -1;

   if side = lag( side) and score < 8 then do;
      if      _subx_ > zp3 then score = 8;
      else if _subx_ > zp2 then score + 4;
      else if _subx_ > zp1 then score + 2;
      else if _subx_ > z00 then score + 1;
      else if _subx_ < zm3 then score = 8;
      else if _subx_ < zm2 then score + 4;
      else if _subx_ < zm1 then score + 2;
      else                      score + 1;
      end;
   else do;
      if      _subx_ > zp3 then score = 8;
      else if _subx_ > zp2 then score = 4;
      else if _subx_ > zp1 then score = 2;
      else if _subx_ > z00 then score = 1;
      else if _subx_ < zm3 then score = 8;
      else if _subx_ < zm2 then score = 4;
      else if _subx_ < zm1 then score = 2;
      else                      score = 1;
      end;

   if score > 7 then do
      cscore  = 'YELLOW  ';  /* highlight high score */
      _tests_ = '1       ';  /*    signal test score */
      zlabel  = 'Score= 8';
      end;
   else do;
      cscore  = 'GRAY    ';
      _tests_ = '        ';
      zlabel  = '        ';
      end;

   label score='Scores';
   run;

goptions colors=(black red green blue);

title 'Zone Control Chart';

proc shewhart table=zones;
   xchart x*subgrp(score)/zones
                          cblockvar    = (cscore)
                          cblocklab    = gray
                          cframe       = blue
                          cconnect     = white
                          blocklabtype = scaled
                          blockrep
                          novangle;
   run;

proc shewhart table=zones;
   xchart x*subgrp / zones
                     test       = 1
                     cframe     = gray
                     ctest      = white
                     testlabel  = (zlabel)
                     novangle;
   run;

goptions reset=all;