Resources

Mean and Range (X-Bar and R) Charts

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: SHWXR1                                              */
/*   TITLE: Mean and Range (X-Bar and R) Charts                 */
/* PRODUCT: QC                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Shewhart Charts, Mean and Range Charts,             */
/*   PROCS: SHEWHART                                            */
/*    DATA:                                                     */
/*                                                              */
/*     REF: SAS/QC Software:  Usage and Reference, Version 6,   */
/*          First Edition, Volume 1 and Volume 2                */
/*                                                              */
/****************************************************************/

data Wafers;
   input Batch @;
   do i=1 to 5;
      input Diameter @;
      output;
   end;
   drop i;
   datalines;
 1  35.00 34.99 34.99 34.98 35.00
 2  35.01 34.99 34.99 34.98 35.00
 3  34.99 35.00 35.00 35.00 35.00
 4  35.01 35.00 34.99 34.99 35.00
 5  35.00 34.99 34.98 34.99 35.00
 6  34.99 34.99 35.00 35.00 35.00
 7  35.01 34.98 35.00 35.00 34.99
 8  35.00 35.00 34.99 34.98 34.99
 9  34.99 34.98 34.98 35.01 35.00
10  34.99 35.00 35.01 34.99 35.01
11  35.01 35.00 35.00 34.98 34.99
12  34.99 34.99 35.00 34.98 35.01
13  35.01 34.99 34.98 34.99 34.99
14  35.00 35.00 34.99 35.01 34.99
15  34.98 34.99 34.99 34.98 35.00
16  34.99 35.00 35.00 35.01 35.00
17  34.98 34.98 34.99 34.99 34.98
18  35.01 35.02 35.00 34.98 35.00
19  34.99 34.98 35.00 34.99 34.98
20  34.99 35.00 35.00 34.99 34.99
21  35.00 34.99 34.99 34.98 35.00
22  35.00 35.00 35.01 35.00 35.00
23  35.02 35.00 34.98 35.02 35.00
24  35.00 35.00 34.99 35.01 34.98
25  34.99 34.99 34.99 35.00 35.00
;


title 'The Data Set Wafers';
proc print data=Wafers noobs;
run;

ods graphics off;
title 'Mean and Range Charts for Diameters';
proc shewhart data=Wafers;
   xrchart Diameter*Batch;
run;

data Wafersum;
   input Batch DiameterX DiameterR;
   DiameterN = 5;
   datalines;
 1  34.992  0.02
 2  34.994  0.03
 3  34.998  0.01
 4  34.998  0.02
 5  34.992  0.02
 6  34.996  0.01
 7  34.996  0.03
 8  34.992  0.02
 9  34.992  0.03
10  35.000  0.02
11  34.996  0.03
12  34.994  0.03
13  34.992  0.03
14  34.998  0.02
15  34.988  0.02
16  35.000  0.02
17  34.984  0.01
18  35.002  0.04
19  34.988  0.02
20  34.994  0.01
21  34.992  0.02
22  35.002  0.01
23  35.004  0.04
24  34.996  0.03
25  34.994  0.01
;

title 'Summary Data Set for Wafer Diameters';
proc print data=Wafersum(obs=5) noobs;
run;

options nogstyle;
goptions ftext=swiss;
title 'Mean and Range Charts for Diameters';
symbol value = dot color = salmon;
proc shewhart history=Wafersum;
   xrchart Diameter*Batch / cframe   = bigb
                            cinfill  = ywh
                            cconnect = salmon
                            coutfill = yellow;
run;
options gstyle;

proc shewhart data=Wafers;
   xrchart Diameter*Batch / outhistory = Waferhist
                            nochart;
run;

title 'Summary Data Set for Wafer Diameters';
proc print data=Waferhist(obs=5) noobs;
run;

proc shewhart data=Wafers;
   xrchart Diameter*Batch / outlimits = Waferlim
                            nochart;
run;

title 'Control Limits for Wafer Diameters';
proc print data=Waferlim noobs;
run;

proc shewhart data=Wafers;
   xrchart Diameter*Batch / outlimits = Waferlim2
                            usl       = 35.03
                            lsl       = 34.97
                            nochart;
run;

title 'Control Limits and Capability Indices';
proc print data=Waferlim2 noobs;
run;

proc shewhart data=Wafers;
   xrchart Diameter*Batch / outtable=Wafertab
                            nochart;
run;

title 'Summary Statistics and Control Limit Information';
proc print data=Wafertab noobs;
run;

title 'Mean and Range Charts for Diameters';
proc shewhart table=Wafertab;
   xrchart Diameter*Batch;
run;

data Wafers2;
   input Batch @;
   do i=1 to 5;
      input Diameter @;
      output;
   end;
   drop i;
   datalines;
26 34.99 34.99 35.00 34.99 35.00
27 34.99 35.01 34.98 34.98 34.97
28 35.00 34.99 34.99 34.99 35.01
29 34.98 34.96 34.98 34.98 34.99
30 34.98 35.00 34.98 34.98 34.99
31 35.00 35.00 34.99 35.01 35.01
32 35.00 34.99 34.98 34.98 35.00
33 34.98 35.00 34.99 35.00 35.01
34 35.00 34.97 35.00 34.99 35.01
35 34.99 34.99 34.98 34.99 34.98
36 35.01 34.98 34.99 34.99 35.00
37 35.01 34.99 34.97 34.98 35.00
38 34.98 34.99 35.00 34.98 35.00
39 34.99 34.99 34.99 34.99 35.01
40 34.99 35.01 35.00 35.01 34.99
41 34.99 35.00 34.99 34.98 34.99
42 35.00 34.99 34.98 34.99 35.00
43 34.99 34.98 34.98 34.99 34.99
44 35.00 35.00 34.98 35.00 34.99
45 34.99 34.99 35.00 34.99 34.99
;

ods graphics on;
proc shewhart data=Wafers2 limits=Waferlim;
   xrchart Diameter*Batch;
run;