Resources

Uniformly Weighted Moving Average Chart

/*******************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                    */
/*                                                                 */
/*    NAME: MACMA1                                                 */
/*   TITLE: Uniformly Weighted Moving Average Chart                */
/* PRODUCT: QC                                                     */
/*  SYSTEM: ALL                                                    */
/*    KEYS: Moving Average Charts,                                 */
/*   PROCS: MACONTROL                                              */
/*    DATA:                                                        */
/*                                                                 */
/* SUPPORT: saswgr                                                 */
/*     REF: PROC MACONTROL, MACHART Statement, Getting Started     */
/*                                                                 */
/*******************************************************************/

data Clips1;
   input Day @ ;
   do i=1 to 5;
      input Gap @ ;
      output;
   end;
   drop i;
   datalines;
 1  14.76  14.82  14.88  14.83  15.23
 2  14.95  14.91  15.09  14.99  15.13
 3  14.50  15.05  15.09  14.72  14.97
 4  14.91  14.87  15.46  15.01  14.99
 5  14.73  15.36  14.87  14.91  15.25
 6  15.09  15.19  15.07  15.30  14.98
 7  15.34  15.39  14.82  15.32  15.23
 8  14.80  14.94  15.15  14.69  14.93
 9  14.67  15.08  14.88  15.14  14.78
10  15.27  14.61  15.00  14.84  14.94
11  15.34  14.84  15.32  14.81  15.17
12  14.84  15.00  15.13  14.68  14.91
13  15.40  15.03  15.05  15.03  15.18
14  14.50  14.77  15.22  14.70  14.80
15  14.81  15.01  14.65  15.13  15.12
16  14.82  15.01  14.82  14.83  15.00
17  14.89  14.90  14.60  14.40  14.88
18  14.90  15.29  15.14  15.20  14.70
19  14.77  14.60  14.45  14.78  14.91
20  14.80  14.58  14.69  15.02  14.85
;

title 'The Data Set Clips1';
proc print data=Clips1(obs=15) noobs;
run;

ods graphics off;
title 'Moving Average Chart for Gap Measurements';
proc macontrol data=Clips1;
   machart Gap*Day / span=3;
run;

data Clipsum;
   input Day GapX GapS;
   GapN=5;
   datalines;
 1  14.904  0.18716
 2  15.014  0.09317
 3  14.866  0.25006
 4  15.048  0.23732
 5  15.024  0.26792
 6  15.126  0.12260
 7  15.220  0.23098
 8  14.902  0.17254
 9  14.910  0.19824
10  14.932  0.24035
11  15.096  0.25618
12  14.912  0.16903
13  15.138  0.15928
14  14.798  0.26329
15  14.944  0.20876
16  14.896  0.09965
17  14.734  0.22512
18  15.046  0.24141
19  14.702  0.17880
20  14.788  0.16634
;

title 'The Data Set Clipsum';
proc print data=Clipsum(obs=5) noobs;
run;

options nogstyle;
symbol color=salmon h=0.8;
title 'Moving Average Chart for Gap Measurements';
proc macontrol history=Clipsum;
   machart Gap*Day / span     = 3
                     cframe   = steel
                     cinfill  = vpab
                     cconnect = yellow
                     coutfill = salmon;
run;
options gstyle;

title 'Summary Data Set for Gap Measurements';
proc macontrol data=Clips1;
   machart Gap*Day / span       = 3
                     outhistory = Cliphist
                     nochart;
run;

proc print data=Cliphist(obs=5) noobs;
run;

title 'Control Limit Parameters';
proc macontrol data=Clips1;
   machart Gap*Day / span      = 3
                     outlimits = Cliplim
                     nochart;
run;

proc print data=Cliplim noobs;
run;

title 'Summary Statistics and Control Limits';
proc macontrol data=Clips1;
   machart Gap*Day / span     = 3
                     outtable = Cliptab
                     nochart;
run;

proc print data=Cliptab noobs;
run;

data Clips1a;
   label Gap='Gap Measurement (mm)';
   input Day @;
   do i=1 to 5;
      input Gap @;
      output;
   end;
   drop i;
   datalines;
21  14.86 15.01 14.67 14.67 15.07
22  14.93 14.53 15.07 15.10 14.98
23  15.27 14.90 15.12 15.10 14.80
24  15.02 15.21 14.93 15.11 15.20
25  14.90 14.81 15.26 14.57 14.94
26  14.78 15.29 15.13 14.62 14.54
27  14.78 15.15 14.61 14.92 15.07
28  14.92 15.31 14.82 14.74 15.26
29  15.11 15.04 14.61 15.09 14.68
30  15.00 15.04 14.36 15.20 14.65
31  14.99 14.76 15.18 15.04 14.82
32  14.90 14.78 15.19 15.06 15.06
33  14.95 15.10 14.86 15.27 15.22
34  15.03 14.71 14.75 14.99 15.02
35  15.38 14.94 14.68 14.77 14.83
36  14.95 15.43 14.87 14.90 15.34
37  15.18 14.94 15.32 14.74 15.29
38  14.91 15.15 15.06 14.78 15.42
39  15.34 15.34 15.41 15.36 14.96
40  15.12 14.75 15.05 14.70 14.74
;

ods graphics on;
title 'Moving Average Chart for Second Set of Gap Measurements';
proc macontrol data=Clips1a limits=Cliplim;
   machart Gap*Day / odstitle=title;
run;