Resources

Q Charts for Individual Measurements

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: SHWQCHT1                                            */
 /*   TITLE: Q Charts for Individual Measurements                */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: Shewhart Charts, Short Run Process Control, Q Chart,*/
 /*   PROCS: SHEWHART                                            */
 /*    DATA: Found in Reference Below                            */
 /*                                                              */
 /*     REF: Quesenberry, C. P. (1991). "SPC Q Charts For Start- */
 /*          Up Processes and Short or Long Runs"  Journal of    */
 /*          Quality Technology, Vol. 23, No. 3, pp. 213-224.    */
 /*                                                              */
 /*    NOTE: See Example 1, pg. 219 of above Reference.          */
 /*                                                              */
 /****************************************************************/
 options ps=60 ls=80 nodate;

 /*******************************************************/
 /*                                                     */
 /*  This data was generated from a Normal Distribution */
 /*       with mean of 15 and variance of .0004.        */
 /*                                                     */
 /*******************************************************/

data sample;
   input x @@;
   subgrp = _n_;
cards;
14.984  14.980  15.008  15.016  15.024
15.004  15.044  14.988  15.012  14.970
15.014  15.014  14.991  14.996  15.024
14.973  14.955  14.949  15.029  15.025
14.993  14.992  14.955  15.006  14.988
15.017  15.020  15.026  15.028  14.994
15.009  15.028  14.981  15.021  15.004
15.003  14.997  15.028  14.998  15.014
15.014  14.970  15.004  14.985  14.967
14.983  14.999  14.994  14.997  14.995
;


 /****************************************/
 /*  Case I:                             */
 /*  Assume mu and sigma are known.      */
 /*  mu = 15, sigma = .02                */
 /****************************************/

data qchart1a;
   set sample;
   q = ( x - 15 ) / .02;
run;


title 'Q-Chart for Process Mean (Parameters Known)';
symbol1 v=dot h=.5 c=white;
proc shewhart data=qchart1a;
   irchart q*subgrp / mu0      = 0
                      sigma0   = 1
                      cinfill  = blue
                      cframe   = gray
                      czones   = yellow
                      llimits  = 1
                      xsymbol  = 'CL=0'
                      ndecimal = 0
                      nolimitslegend
                      novangle
                      nochart2;
   label q      = 'Standardized Value';
   label subgrp = 'Observation Number';
   run;

 /*******************************************/
 /*                                         */
 /* The test for (r=0) below removes ties   */
 /* in the dataset from the computations.   */
 /*                                         */
 /*******************************************/

data qchart1b;
   set sample;
   retain lastx;
   if (mod(_n_,2) = 0) then do;
      r = x - lastx;
      if (r = 0) then
         q = .;
      else
         q = probit( probchi( (r*r) / (2*.0004), 1 ) );
      output;
      end;
   lastx = x;
   run;

title 'Q-Chart for Process Variance (Parameters Known)';
proc shewhart data=qchart1b;
   irchart q*subgrp / mu0      = 0
                      sigma0   = 1
                      cinfill  = blue
                      cframe   = gray
                      czones   = yellow
                      llimits  = 1
                      xsymbol  = 'CL=0'
                      ndecimal = 0
                      nolimitslegend
                      novangle
                      nochart2;
   label q      = 'Standardized Value';
   label subgrp = 'Observation Number';
   run;


 /****************************************/
 /*  Case II:                            */
 /*  Assume mu and sigma are unknown.    */
 /****************************************/


data qchart2a;
   set sample;
   retain lastx lxbar ls2r;
   if (_n_ > 2 ) then do;
      xbar = (1/_n_)*( (_n_-1)*lxbar + x);
      s2r  = ((_n_-2)/(_n_-1))*ls2r + (1/_n_)*(x - lxbar)**2;
      temp = sqrt( (_n_-1)/_n_ )*((x - lxbar)/sqrt(ls2r));
      q    = probit(probt(temp, _n_ - 2));
      end;
   if (_n_ = 1 ) then do;
      xbar = x;
      s2r  = 0;
      end;
   if (_n_ = 2 ) then do;
      xbar = .5*(lxbar+x);
      s2r  = (lastx - xbar)**2 + (x - xbar)**2;
      end;
   lastx = x;
   lxbar = xbar;
   ls2r  = s2r;
   run;

title 'Q-Chart for Process Mean (Parameters Unknown)';
proc shewhart data=qchart2a;
   irchart q*subgrp / mu0      = 0
                      sigma0   = 1
                      cinfill  = blue
                      cframe   = gray
                      czones   = yellow
                      llimits  = 1
                      xsymbol  = 'CL=0'
                      ndecimal = 0
                      nolimitslegend
                      novangle
                      nochart2;
   label q      = 'Standardized Value';
   label subgrp = 'Observation Number';
   run;

 /*******************************************/
 /*                                         */
 /* The test for (r=0) below removes ties   */
 /* in the dataset from the computations.   */
 /*                                         */
 /*******************************************/

data qchart2b;
   set sample;
   retain lastx lastsum;
   if (mod(_n_,2) = 0) then do;
      r = x - lastx;
      if (_n_ = 2 ) then do;
         sum = r*r;
         end;
      else do;
         sum = lastsum + r**2;
         if (r=0) then
           q = .;
         else do;
            nu = _n_/2 - 1;
            q  = probit( probf( (nu*r*r) / (lastsum),1,nu) );
            end;
         output;
         end;
      lastsum = sum;
      end;
   lastx = x;
   run;

title 'Q-Chart for Process Variance (Parameters Unknown)';
proc shewhart data=qchart2b;
   irchart q*subgrp / mu0      = 0
                      sigma0   = 1
                      cinfill  = blue
                      cframe   = gray
                      czones   = yellow
                      llimits  = 1
                      xsymbol  = 'CL=0'
                      ndecimal = 0
                      nolimitslegend
                      novangle
                      nochart2;
   label q      = 'Standardized Value';
   label subgrp = 'Observation Number';
   run;

goptions reset=all;