Stratifying Data with a Classification Variable

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: SHWSYM1                                             */
/*   TITLE: Stratifying Data with a Classification Variable     */
/* PRODUCT: QC                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Shewhart Charts, Classification 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;
symbol1 c=orange value=star      h=3.0 pct;
symbol2 c=red    value=dot       h=3.0 pct;
symbol3 c=blue   value=triangle  h=3.0 pct;
title 'Control Chart for Diameter Stratified by Machine';
proc shewhart history=Parts;
   xchart Diam*Sample=Machine / stddeviations
                                symbollegend = legend1;
   label Sample = 'Sample Number'
         DiamX  = 'Average Diameter' ;
   legend1 frame label=('Machine');
run;