Q Charts for Individual Measurements
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: SHWQCHT2 */
/* TITLE: Q Charts for Individual Measurements */
/* 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 2, pg. 219 of above Reference. */
/* */
/****************************************************************/
options ps=60 ls=80 nodate;
/***********************************************************/
/* */
/* This program compares the behavior of the q-charts */
/* for the 2 cases, 1) where parameters are known and */
/* 2) where parameters are unknown. */
/* */
/* The dataset below has 30 observations, the first 20 */
/* are from a normal distribution with mean of 15 and */
/* variance of .0004, in the last 10 observations the */
/* mean has increased by .02 (or one standard deviation). */
/* */
/***********************************************************/
data sample;
seed = 27951;
do i = 1 to 30;
subgrp = i;
if ( i < 21 ) then do;
x = 15 + .02*rannor(seed);
group = 'Mean of 15 ';
gcolor = 'yellow';
end;
else do;
x = 15.02 + .02*rannor(seed);
group = 'Mean of 15.02';
gcolor = 'red';
end;
output;
end;
run;
/****************************************/
/* Case I: */
/* Assume mu and sigma are known. */
/* mu = 15, sigma = .02 */
/****************************************/
data qchart1;
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=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 sample;
retain lastx lxbar ls2r;
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;
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;
lastx = x;
lxbar = xbar;
ls2r = s2r;
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'
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
goptions reset=all;