Chapter Contents Previous Next
 XCHART Statement

## Example 12.1: Cusum and Standard Deviation Charts

 See CUSXS in the SAS/QC Sample Library

When you are working with subgrouped data, it can be helpful to accompany a cusum chart for means with a Shewhart s chart for monitoring the variability of the process. This example creates this combination for the variable WEIGHT in the data set OIL (see "Creating a V-Mask Cusum Chart from Raw Data" ).

The first step is to create a one-sided cusum chart for means that detects a shift of one standard error ()below the target mean.

   proc cusum data=oil;
xchart weight*hour /
nochart                    /* suppress display         */
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 = tabcusum        /* save the results         */
( drop   = _var_ _subn_ _subx_ _exlim_
rename = ( _cusum_ = _subx_ _h_ = _uclx_ ) )
;
run;


The results are saved in an OUTTABLE= data set named TABCUSUM. The cusum variable (_CUSUM_) and the decision interval variable (_H_) are renamed to _SUBX_ and _LCLX_ so that they can later be read by the SHEWHART procedure.

The next step is to construct a Shewhart and s chart for WEIGHT and save the results in a data set named TABXSCHT.

   proc shewhart data=oil;
xschart weight*hour /
nochart                    /* suppress display */
outtable = tabxscht        /* save the results */
( drop = _subx_  _uclx_ );
run;


Note that the variables _SUBX_ and _UCLX_ are dropped from TABXSCHT.

The third step is to merge the data sets TABCUSUM and TABXSCHT.

   data taball;
merge tabxscht tabcusum; by hour;
_mean_ = _uclx_ * 0.5;
_lclx_ = 0.0;
run;

proc print;
run;

The variable _LCLX_ is assigned the role of the lower limit for the cusums, and the variable _MEAN_ is assigned a dummy value. Now, TABALL, which is listed in Output 12.1.1, has the structure required for a TABLE= data set used with the XSCHART statement in the SHEWHART procedure (see "TABLE= Data Set" in Chapter 44, "XSCHART Statement").

Output 12.1.1: Listing of the Data Set TABALL

 Obs _VAR_ hour _SIGMAS_ _LIMITN_ _SUBN_ _LCLX_ _MEAN_ _EXLIM_ _LCLS_ _SUBS_ _S_ _UCLS_ _EXLIMS_ _subx_ _uclx_ 1 weight 1 3 4 4 0 1.5 0 0.059640 0.049943 0.11317 0.00 3 2 weight 2 3 4 4 0 1.5 0 0.090220 0.049943 0.11317 0.00 3 3 weight 3 3 4 4 0 1.5 0 0.076346 0.049943 0.11317 0.00 3 4 weight 4 3 4 4 0 1.5 0 0.025552 0.049943 0.11317 0.00 3 5 weight 5 3 4 4 0 1.5 0 0.026500 0.049943 0.11317 0.00 3 6 weight 6 3 4 4 0 1.5 0 0.075617 0.049943 0.11317 0.30 3 7 weight 7 3 4 4 0 1.5 0 0.037242 0.049943 0.11317 0.00 3 8 weight 8 3 4 4 0 1.5 0 0.059290 0.049943 0.11317 0.18 3 9 weight 9 3 4 4 0 1.5 0 0.005737 0.049943 0.11317 1.21 3 10 weight 10 3 4 4 0 1.5 0 0.046522 0.049943 0.11317 0.62 3 11 weight 11 3 4 4 0 1.5 0 0.040542 0.049943 0.11317 0.00 3 12 weight 12 3 4 4 0 1.5 0 0.056103 0.049943 0.11317 0.00 3

The final step is to use the SHEWHART procedure to read TABALL as a TABLE= data set and to display the cusum and s charts.

   title 'Cusum Chart for Mean and s chart';
symbol v=dot c=salmon;
proc shewhart table=taball;
xschart weight * hour /
ucllabel = 'h=3.0'
nolimitslegend
noctl
split    = '/'
nolegend
cinfill  = ywh
coutfill = yellow
cconnect = salmon
cframe   = bigb;
label _subx_ = 'Lower Cusum/Std Dev';
run;


The central line for the primary (cusum) chart is suppressed with the NOCTL option, and the default 3 Limits legend is suppressed with the NOLIMITLEGEND option. The charts are shown in Output 12.1.2.

Output 12.1.2: Combined Cusum Chart and s Chart

The process variability is stable, and there is no signal of a downward shift in the process mean.

 Chapter Contents Previous Next Top