Resources

Upper and Lower One-Sided Cusum Charts

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: CUSUPLO                                             */
/*   TITLE: Upper and Lower One-Sided Cusum Charts              */
/* PRODUCT: QC                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Cusum Charts,                                       */
/*   PROCS: CUSUM SHEWHART                                      */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: saswgr                                              */
/*     REF: PROC CUSUM, XCHART Statement, Getting Started 1     */
/*                                                              */
/****************************************************************/

data Oil;
   label Hour = 'Hour';
   input Hour @;
   do i=1 to 4;
      input Weight @;
      output;
   end;
   drop i;
   datalines;
 1  8.024  8.135  8.151  8.065
 2  7.971  8.165  8.077  8.157
 3  8.125  8.031  8.198  8.050
 4  8.123  8.107  8.154  8.095
 5  8.068  8.093  8.116  8.128
 6  8.177  8.011  8.102  8.030
 7  8.129  8.060  8.125  8.144
 8  8.072  8.010  8.097  8.153
 9  8.066  8.067  8.055  8.059
10  8.089  8.064  8.170  8.086
11  8.058  8.098  8.114  8.156
12  8.147  8.116  8.116  8.018
;



proc cusum data=Oil;
   xchart Weight*Hour /
      nochart
      mu0=8.100        /* target mean for process  */
      sigma0=0.050     /* known standard deviation */
      delta=1          /* shift to be detected     */
      h=3              /* cusum parameter h        */
      k=0.5            /* cusum parameter k        */
      scheme=onesided
      outtable = tabupper
         ( drop   = _subx_ _subs_ _exlim_
           rename = ( _cusum_ = _subx_ _h_ = _uclx_ ) )
      ;
   xchart Weight*Hour /
      nochart
      mu0=8.100        /* target mean for process  */
      sigma0=0.050     /* known standard deviation */
      delta=-1         /* shift to be detected     */
      h=3              /* cusum parameter h        */
      k=0.5            /* cusum parameter k        */
      scheme=onesided
      outtable = tablower
         ( drop   = _var_ _subn_ _subx_ _subs_ _exlim_
           rename = ( _cusum_ = _subs_ _h_ = _ucls_ ) )
      ;
run;

data Tabboth;
   merge tabupper tablower; by Hour;
   _mean_   = _uclx_ * 0.5;
   _s_      = _ucls_ * 0.5;
   _lclx_   = 0.0;
   _lcls_   = 0.0;
run;

ods graphics on;
title 'Upper and Lower Cusums';
proc shewhart table=Tabboth;
   xschart Weight * Hour /
      nolimitslegend
      markers
      odstitle  = title
      ucllabel  = 'h=3.0'
      ucllabel2 = 'h=3.0'
      ypct1     = 50
      vref      = 1 2
      vref2     = 1 2
      noctl
      noctl2
      split = '/'
      nolegend ;
   label _subx_ = 'Upper Sum/Lower Sum';
run;