Q Charts for Process Means
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: SHWQCHT3 */
/* TITLE: Q Charts for Process Means */
/* PRODUCT: QC */
/* SYSTEM: ALL */
/* KEYS: Shewhart Charts, Short Run Process Control, Q Chart,*/
/* PROCS: SHEWHART */
/* DATA: */
/* */
/* 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 3, pg. 219 of above Reference. */
/* */
/****************************************************************/
options ps=60 ls=80 nodate;
/*************************************************************/
/* */
/* The following data is 20 samples of size 5. The first 12 */
/* samples have a mean of 10 and standard deviation of .01. */
/* The last 8 samples have the same standard deviation, but */
/* the mean has increased to 10.01. */
/* */
/* The first plot assumes the parameters are known, while */
/* the second plot assumes the parameters are unknown. */
/* Comparing the plots shows how each reacts to a shift */
/* in the mean. */
/* */
/*************************************************************/
data sample;
seed = 27951;
do i = 1 to 20;
subgrp = i;
do j = 1 to 5;
if ( i < 13 ) then do;
x = 10 + .01*rannor(seed);
end;
else do;
x = 10.01 + .01*rannor(seed);
end;
output;
end;
end;
run;
/****************************************/
/* Case I: */
/* Assume mu and sigma are known. */
/* mu = 10, sigma = .01 */
/****************************************/
/****************************************/
/* This proc call calculates subgroup */
/* means and standard deviations. */
/****************************************/
proc shewhart data=sample;
xchart x*subgrp / nochart
outhistory = hist1
stddeviations;
run;
data qchart1;
set hist1;
if ( _n_ < 13 ) then do;
group = 'Mean of 10 ';
gcolor = 'yellow';
end;
else do;
group = 'Mean of 10.01';
gcolor = 'red';
end;
q = sqrt(xn)*( xx - 10 ) / .01;
run;
title 'Q-Chart for Process Mean (Parameters Known)';
symbol1 v=dot h=.5 c=white;
proc shewhart data=qchart1;
irchart q*subgrp (group) /
mu0 = 0
sigma0 = 1
czones = yellow
cframe = gray
cinfill = blue
llimits = 1
xsymbol = 'CL=0'
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
/****************************************/
/* Case II: */
/* Assume mu and sigma are unknown. */
/****************************************/
data qchart2;
set hist1;
retain lgmean lsum ls2sum;
if ( _n_ < 13 ) then do;
group = 'Mean of 10 ';
gcolor = 'yellow';
end;
else do;
group = 'Mean of 10.01';
gcolor = 'red';
end;
if (_n_ = 1 ) then do;
sum = xx;
gmean = xx;
s2sum = xs**2;
end;
else do;
sum = lsum + xx;
gmean = sum / _n_;
s2sum = ls2sum + (xn - 1)*xs**2;
s2pi = s2sum / ((xn - 1)*_n_);
wi = sqrt( ((xn)*(_n_- 1 )*xn)/(_n_*xn ) )
* (xx - lgmean)/sqrt(s2pi);
q = probit( probt(wi, (_n_-1 )*xn ) );
output;
end;
lgmean = gmean;
lsum = sum;
ls2sum = s2sum;
run;
title 'Q-Chart for Process Mean (Parameters Unknown)';
symbol1 v=dot h=.5;
proc shewhart data=qchart2;
irchart q*subgrp (group) /
mu0 = 0
sigma0 = 1
czones = yellow
cinfill = blue
cframe = gray
llimits = 1
xsymbol = 'CL=0'
haxis = 0 to 20 by 2
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
goptions reset=all;