data cans; length comment $16; label hour = 'Hour'; input hour weight comment $16. ; cards; 1 8.024 2 7.971 3 8.125 4 8.123 5 8.068 6 8.177 Pump Adjusted 7 8.229 Pump Adjusted 8 8.072 9 8.066 10 8.089 11 8.058 12 8.147 13 8.141 14 8.047 15 8.125 ; SYMBOL1 VALUE=DOT WIDTH=3; title 'One-Sided CUSUM Analysis'; proc cusum data=cans graphics; xchart weight*hour / mu0 = 8.100 /* Target Mean */ sigma0 = 0.050 /* Known Standard Deviation */ delta = 1 /* Shift to be Detected */ h = 3 /* Decision Interval */ k = 0.5 /* Reference Value */ scheme = onesided /* One-Sided Scheme */ outtable = qsum tablesummary tablecomp haxis=1 to 15 dataunits; label weight = 'Cusum of Weight'; run; data qsum; set qsum; h=3; k=.5; sigma=.05; aim=8.1; ** 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 hour; var xbar n cusum_l hsigma cusum_h flag; TITLE 'Upper One-sided CUSUM with Reset after Signal'; run;