Resources

Short Run Process Control

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: SHWSRUN                                             */
/*   TITLE: Short Run Process Control                           */
/* PRODUCT: QC                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Shewhart Charts, Short Run Process Control,         */
/*   PROCS: SHEWHART GLM MEANS                                  */
/*    DATA:                                                     */
/*                                                              */
/*     REF: SAS/QC Software:  Usage and Reference, Version 6,   */
/*          First Edition, Volume 1 and Volume 2                */
/*                                                              */
/****************************************************************/

data Old;
   input Sample Prodtype $ Diameter;
   datalines;
 1  M3  13.99
 2  M3  14.69
 3  M3  13.86
 4  M3  14.32
 5  M3  13.23
 6  M1  17.55
 7  M1  14.26
 8  M1  14.62
 9  M1  12.97
10  M2  16.18
11  M2  15.29
12  M2  16.20
13  M3  13.89
14  M3  12.71
15  M3  14.32
16  M3  15.35
17  M2  15.08
18  M2  14.72
19  M2  14.79
20  M2  15.27
21  M2  15.95
22  M1  14.78
23  M1  15.19
24  M1  15.41
25  M1  16.26
26  M3  16.68
27  M3  15.60
28  M3  14.86
29  M3  16.67
30  M3  14.35
;

title;
proc print data=Old noobs;
run;

data Nomval;
   length Prodtype $2;
   input Prodtype Nominal;
   datalines;
M1 15.0
M2 15.5
M3 14.8
M4 15.2
;

title;
proc print data=Nomval noobs;
run;

proc sort data=Old;
   by Prodtype;
run;

data Old;
   format Diff 5.2 ;
   merge Nomval Old(in = a);
      by Prodtype;
   if a;
   Diff = Diameter - Nominal;
run;

proc sort data=Old;
   by Sample;
run;

title;
proc print data=Old noobs;
   var Sample Prodtype Diameter Nominal Diff;
run;

proc sort data=Old;
   by Prodtype;
run;

proc shewhart data=Old;
   irchart Diff*Sample /
      nochart
      outlimits=Baselim;
   by Prodtype;
run;

title 'Control Limits By Product Type';
proc print data=Baselim noobs;
run;

proc means data=Baselim noprint;
   var _r_;
   output out=Difflim (keep=_r_) mean=_r_;
run;

data Difflim;
   set Difflim;
   drop _r_;
   length _var_ _subgrp_ $ 8;
   _var_    = 'Diff';
   _subgrp_ = 'Sample';
   _mean_   = 0.0;
   _stddev_ = _r_ / d2(2);
   _limitn_ = 2;
   _sigmas_ = 3;
run;

title 'Control Limit Parameters For Differences';
proc print data=Difflim noobs;
run;

data new;
   input Sample Prodtype $ Diameter;
   datalines;
31  M2  14.69
32  M2  15.39
33  M2  14.56
34  M2  15.02
35  M2  13.93
36  M1  17.55
37  M1  14.26
38  M3  14.42
39  M3  12.77
40  M3  15.48
41  M3  14.59
42  M2  16.20
43  M2  14.59
44  M2  13.41
45  M2  15.02
46  M2  16.05
47  M2  15.08
48  M2  14.72
49  M2  14.79
50  M1  14.77
51  M1  15.45
52  M1  14.28
53  M1  14.69
54  M2  15.41
55  M2  16.26
56  M2  17.38
57  M3  15.60
58  M3  14.86
59  M3  16.67
60  M3  14.35
;

proc sort data=new;
   by Prodtype;
run;

data new;
   format Diff 5.2 ;
   merge Nomval new(in = a);
      by Prodtype;
   if a;
   Diff = Diameter - Nominal;
   label Sample   = 'Sample Number'
         Prodtype = 'Model';
run;

proc sort data=new;
   by Sample;
run;

ods graphics off;
symbol1 v=dot    c=blue  h=3.0 pct;
symbol2 v=plus   c=red   h=3.0 pct;
symbol3 v=circle c=green h=3.0 pct;
title 'Chart for Difference from Nominal';
proc shewhart data=new limits=Difflim;
   irchart Diff*Sample=Prodtype / split    = '/';
   label Diff = 'Difference/Moving Range';
run;

symbol h=3.0 pct;
title 'Chart for Difference from Nominal';
proc shewhart data=new (rename=(Prodtype=_phase_)) limits=Difflim;
   irchart Diff*Sample /
      readphases = all
      phaseref
      phasebreak
      phaselegend
      split      = '/';
   label Diff = 'Difference/Moving Range';
run;

data Difflim;
   set Difflim;
   _var_    = 'Diameter';
   _limitn_ = 1;
run;

title 'Differences and Nominal Values';
proc shewhart data=new limits=Difflim;
   xchart Diameter*Sample (Prodtype) /
      nolimitslegend
      nolegend
      split         = '/'
      blockpos      = 3
      blocklabtype  = scaled
      blocklabelpos = left
      xsymbol       = xbar
      trendvar      = Nominal;
   label Diameter   = 'Difference/Nominal'
         Prodtype   = 'Product';
run;

proc sort data=Old;
   by Prodtype;
run;

proc means data=Old noprint;
   var Diameter;
   by Prodtype;
   output out=Oldmean (keep=Prodtype diammean) mean=diammean;
run;

data Old;
   merge Old Oldmean;
      by Prodtype;
   absdev = abs( Diameter - diammean );
run;

proc means data=Old noprint;
  var absdev;
  by Prodtype;
  output out=stats n=n mean=mean css=css std=std;
run;

title;
proc glm data=Old outstat=glmout;
   class Prodtype;
   model absdev = Prodtype;
run;

proc sort data=new;
   by Prodtype;
run;

data new;
   keep Sample Prodtype z Diff Diameter Nominal _stddev_;
   label Sample = 'Sample Number';
   format Diff 5.2 ;
   merge Baselim new(in = a);
      by Prodtype;
   if a;
   z = (Diameter - Nominal) / _stddev_ ;
run;

proc sort data=new;
   by Sample;
run;

title 'Standardized Chart';
proc shewhart data=new;
   irchart z*Sample (Prodtype) /
      blocklabtype  = scaled
      mu0           = 0
      sigma0        = 1
      split         = '/';
   label Prodtype = 'Product Classification'
         z = 'Standardized Difference/Moving Range';
run;