Resources

Using Block Variables to Stratify Data

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: SHWBLK                                              */
/*   TITLE: Using Block Variables to Stratify Data              */
/* PRODUCT: QC                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Shewhart Charts, Block Variables,                   */
/*   PROCS: SHEWHART                                            */
/*    DATA:                                                     */
/*                                                              */
/*     REF: SAS/QC Software:  Usage and Reference, Version 6,   */
/*          First Edition, Volume 1 and Volume 2                */
/*                                                              */
/****************************************************************/

data Parts;
   length Machine $ 4;
   input Sample Machine $ Day Shift DiamX DiamS;
   DiamN=6;
   datalines;
 1  A386  01  1  4.32  0.39
 2  A386  01  2  4.49  0.35
 3  A386  01  3  4.44  0.44
 4  A386  02  1  4.45  0.17
 5  A386  02  2  4.21  0.53
 6  A386  02  3  4.56  0.26
 7  A386  03  1  4.63  0.39
 8  A386  03  2  4.38  0.47
 9  A386  03  3  4.47  0.40
10  A455  04  1  4.42  0.37
11  A455  04  2  4.45  0.32
12  A455  04  3  4.62  0.36
13  A455  05  1  4.33  0.31
14  A455  05  2  4.29  0.33
15  A455  05  3  4.17  0.25
16  C334  08  1  4.15  0.28
17  C334  08  2  4.21  0.33
18  C334  08  3  4.16  0.19
19  C334  09  1  4.14  0.13
20  C334  09  2  4.11  0.19
21  C334  09  3  4.10  0.27
22  C334  10  1  3.99  0.14
23  C334  10  2  4.24  0.16
24  C334  10  3  4.23  0.14
25  A386  11  1  4.27  0.28
26  A386  11  2  4.70  0.45
27  A386  11  3  4.51  0.45
28  A386  12  1  4.34  0.16
29  A386  12  2  4.38  0.29
30  A386  12  3  4.28  0.24
31  A386  15  1  4.47  0.26
32  A386  15  2  4.31  0.46
33  A386  15  3  4.52  0.33
;



ods graphics off;
symbol v=dot h=3.0 pct;
title 'Control Chart for Diameter Stratified By Machine';
proc shewhart history=Parts;
   xchart Diam*Sample (Machine) / stddeviations
                                  nolegend ;
   label Sample = 'Sample Number'
         DiamX  = 'Average Diameter' ;
run;

title 'Control Chart for Diameter Stratified By Machine and Day';
proc shewhart history=Parts;
   xchart Diam*Sample (Machine Day) / stddeviations
                                      nolegend
                                      blockpos = 2;
   label Sample = 'Sample Number'
         DiamX  = 'Average Diameter' ;
run;

data Parts2;
   length CMachine $8;
   set Parts;
   if      Machine='A386' then CMachine='vlibg' ;
   else if Machine='A455' then CMachine='yellow' ;
   else if Machine='C334' then CMachine='lipk';
   else                        CMachine='white' ;
run;

title 'Control Chart for Diameter Stratified By Machine and Day';
proc shewhart history=Parts2;
   xchart Diam*Sample (Machine Day) / stddeviations
                                      nolegend
                                      blockpos  = 3
                                      cblockvar = CMachine;
   label Sample  = 'Sample Number'
         DiamX   = 'Average Diameter'
         Day     = 'Date of Production in June'
         Machine = 'Machine in Use';
run;

data Parts3;
   length CDay $8;
   set Parts2;
   if      Day='01' then CDay='white';
   else if Day='02' then CDay='ligr' ;
   else if Day='03' then CDay='white' ;
   else if Day='04' then CDay='ligr';
   else if Day='05' then CDay='white' ;
   else if Day='08' then CDay='ligr' ;
   else if Day='09' then CDay='white';
   else if Day='10' then CDay='ligr' ;
   else if Day='11' then CDay='white' ;
   else if Day='12' then CDay='ligr';
   else if Day='15' then CDay='white' ;
   else                  CDay='ligr';
run;

title 'Control Chart for Diameter Stratified By Machine and Day';
proc shewhart history=Parts3;
   xchart Diam*Sample (Machine Day) /
      stddeviations
      nolegend
      ltmargin      = 5
      blockpos      = 3
      blocklabelpos = left
      cblockvar     = (CMachine CDay);
   label Sample     = 'Sample Number'
         DiamX      = 'Average Diameter'
         Day        = 'June'
         Machine    = 'Machine';
run;