Multiple Components of Variation
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: SHWMULTC */
/* TITLE: Multiple Components of Variation */
/* PRODUCT: QC */
/* SYSTEM: ALL */
/* KEYS: Shewhart Charts, Variance Components Analysis, */
/* PROCS: SHEWHART MIXED */
/* DATA: */
/* */
/* REF: SAS/QC Software: Usage and Reference, Version 6, */
/* First Edition, Volume 1 and Volume 2 */
/* */
/****************************************************************/
data Film;
drop i;
length Lane $1;
label Lane = 'Lane';
label Testval = 'Test Value';
label Sample = 'Sample';
input date @;
Sample=_n_;
do i=1 to 4;
input Testval @@;
if i=1 then Lane='A';
if i=2 then Lane='B';
if i=3 then Lane='C';
if i=4 then Lane='D';
output;
end;
datalines;
3252 93 87 92 78
3252 87 83 79 77
3262 88 88 73 79
3262 80 83 76 72
3269 91 99 90 79
3269 89 89 92 83
3272 92 93 93 85
3272 83 95 80 87
3272 79 85 91 85
3272 84 96 91 83
3273 89 95 90 93
3274 90 94 93 91
3274 102 104 103 89
3274 93 98 88 83
3279 85 99 91 83
3280 83 95 90 80
3280 92 98 88 84
3280 88 98 91 86
3280 88 95 94 84
3281 89 83 90 76
3281 82 91 96 82
3288 83 88 89 85
3288 88 98 85 85
3288 88 101 93 88
3293 93 103 103 85
3293 101 99 96 84
3293 88 97 97 87
3293 86 90 90 78
3294 91 93 90 86
3294 85 98 93 86
3295 75 76 82 72
3295 76 80 78 75
3296 78 85 71 72
3296 74 84 87 83
3300 90 99 93 89
3301 87 83 94 88
3301 94 92 89 90
3301 158 174 187 90
3302 88 88 93 98
3303 87 108 104 85
3304 107 83 76 81
3304 93 99 94 83
3304 84 103 91 88
3305 97 95 88 81
3305 94 105 98 98
3310 94 102 100 95
3310 96 110 101 95
3311 92 88 90 95
3311 93 97 95 93
3315 76 93 84 75
3315 78 97 97 89
3316 85 97 86 82
3316 88 80 92 94
3317 87 88 94 78
3317 89 83 80 91
3317 88 95 78 75
;
title;
proc print data=Film(obs=5) noobs;
var Sample Lane Testval;
run;
ods graphics off;
proc sort data=Film;
by Lane;
run;
symbol v = dot h = 2.0 pct;
title 'Outlier Analysis';
proc shewhart data=Film;
boxchart Testval*Lane / boxstyle = schematicid
idsymbol = dot
vref = 130
vreflab = 'Outlier Cutoff'
hoffset = 5
nolegend
stddevs
nolimits ;
id Sample;
run;
data Film1;
set Film;
run;
data Film2;
set Film;
if Testval < 130;
symbol h = 2.0 pct;
title 'Variation Within Lane';
proc shewhart data=Film2;
boxchart Testval*Lane / boxstyle = schematicid
boxwidth = 5
idsymbol = dot
hoffset = 5
nolegend
stddevs
nolimits ;
id Sample;
run;
proc sort data=Film2;
by Sample;
run;
symbol h=2.0 pct;
title 'Shewhart Chart for Means and Ranges';
proc shewhart data=Film2;
xrchart Testval*Sample /
split = '/'
npanelpos = 60
limitn = 4
outlimits = RLimits
nolegend
alln;
label Testval='Average Test Value/Range';
run;
title;
proc mixed data=Film2;
class Sample;
model Testval = / s;
random Sample;
ods output solutionf=sf;
ods output covparms=cp;
run;
data cp;
set cp sf;
keep Estimate;
run;
proc transpose data=cp out=Newlim;
run;
data Newlim (keep=_lclx_ _mean_ _uclx_);
set Newlim;
_limitn_ = 4;
_mean_ = col3;
_stddev_ = sqrt(4*col1 + col2);
_lclx_ = _mean_ - 3*_stddev_ / sqrt(_limitn_);
_uclx_ = _mean_ + 3*_stddev_ / sqrt(_limitn_);
output;
run;
data Newlim2;
merge Newlim RLimits (drop=_lclx_ _mean_ _uclx_);
run;
title 'Control Chart with Adjusted Limits';
symbol h = 2.0 pct;
proc shewhart data=Film2 limits=Newlim2;
xrchart Testval*Sample / npanelpos = 60;
label Testval='Average Test Value';
run;
proc sort data=Film;
by Sample;
run;
symbol h = 2.0 pct;
title 'Adjusted Control Chart For Raw Data';
proc shewhart data=Film limits=Newlim2;
xrchart Testval*Sample / npanelpos = 60;
label Testval='Average Test Value';
run;