dm 'log;clear;out;clear;'; OPTIONS NODATE NONUMBER LS=100 ps=80; /* FILENAME TEMP 'CUSUM1.PSEPSF'; GOPTIONS DEVICE=PS GSFNAME=TEMP GSFLEN=132 VSIZE=5 HSIZE=6IN GSFMODE=APPEND; */ data piston; do sample=1 to 25; do item=1 to 5; n= item + 5*(sample-1); input diameter @@; diameter=diameter+70; output; end; end; cards; 4.030 4.002 4.019 3.992 4.008 3.995 3.992 4.001 4.011 4.004 3.988 4.024 4.021 4.005 4.002 4.002 3.996 3.993 4.015 4.009 3.992 4.007 4.015 3.989 4.014 4.009 3.994 3.997 3.985 3.993 3.995 4.006 3.994 4.000 4.005 3.985 4.003 3.993 4.015 3.988 4.008 3.995 4.009 4.005 4.004 3.998 4.000 3.990 4.007 3.995 3.994 3.998 3.994 3.995 3.990 4.004 4.000 4.007 4.000 3.996 3.983 4.002 3.998 3.997 4.012 4.006 3.967 3.994 4.000 3.984 4.012 4.014 3.998 3.999 4.007 4.000 3.984 4.005 3.998 3.996 3.994 4.012 3.986 4.005 4.007 4.006 4.010 4.018 4.003 4.000 3.984 4.002 4.003 4.005 3.997 4.000 4.010 4.013 4.020 4.003 3.988 4.001 4.009 4.005 3.996 4.004 3.999 3.990 4.006 4.009 4.010 3.989 3.990 4.009 4.014 4.015 4.008 3.993 4.000 4.010 3.982 3.984 3.995 4.017 4.013 ; symbol v=dot width=3; proc cusum data=piston; xchart diameter*sample / mu0=74 sigma0=.005 h=4.0 k=0.5 delta=1.0 dataunits haxis=1 to 25 tablesummary tablecomp outtable = qsum ; label diameter='Diameter Cusum' sample = 'Piston Ring Sample'; TITLE 'CUSUM for Piston-Ring Diameters (sigma known)'; proc cusum data=piston; xchart diameter*sample / mu0=74 sigma0=.005 h=4.0 k=0.5 delta=1.0 dataunits haxis=1 to 25 scheme=onesided tablesummary tablecomp; label diameter='Diameter Cusum' sample = 'Piston Ring Sample'; TITLE 'UPPER ONE-SIDED CUSUM'; proc cusum data=piston; xchart diameter*sample / mu0=74 sigma0=.005 h=4.0 k=0.5 delta=-1.0 dataunits scheme=onesided tablesummary tablecomp haxis=1 to 25; label diameter='Diameter Cusum' sample = 'Piston Ring Sample'; TITLE 'LOWER ONE-SIDED CUSUM'; data qsum; set qsum; h=4; k=.5; sigma=.005; aim=74; ** enter values **; xbar=_subx_; n=_subn_; hsigma=h*sigma/sqrt(_subn_); ksigma=k*sigma/sqrt(_subn_); retain cusum_l 0 cusum_h 0; if (-hsigma < cusum_l < hsigma) then do; cusum_l = cusum_l + (aim - ksigma) - xbar; if cusum_l < 0 then cusum_l=0; end; if (-hsigma < cusum_h < hsigma) then do; cusum_h = cusum_h + xbar - (aim + ksigma); if cusum_h < 0 then cusum_h=0; end; if max(cusum_l,cusum_h) ge hsigma then do; if (cusum_l ge hsigma) then do; flag='lower'; output; end; if (cusum_h ge hsigma) then do; flag='upper'; output; end; cusum_l=0; cusum_h=0; end; else output; proc print data=qsum; id sample; var xbar n cusum_l hsigma cusum_h flag; TITLE 'CUSUM with Reset after Signal (sigma known)'; run;