Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Tests for Special Causes

Customizing Tests with DATA Step Programs

See SHWTSC5 in the SAS/QC Sample Library

Occasionally, you may find it necessary to apply customized tests that cannot be specified with the TESTS= option. You can program your own tests as follows:

  1. Run the SHEWHART procedure without the TESTS= option and save the results in an OUTTABLE= data set. Use the NOCHART option to suppress the display of the chart.
  2. Use a DATA step program to apply your tests to the subgroup statistics in the OUTTABLE= data set. If tests are signaled at certain subgroups, save these results as values of a flag variable named _TESTS_, which should be a character variable of length 8. Recall that each observation of an OUTTABLE= data set corresponds to a subgroup. Assign the character i to the i th character of _TESTS_ if the i th customized test is signaled at that subgroup (otherwise, assign a blank character).
  3. Run the procedure reading the modified data set as a TABLE= data set.

The following example illustrates these steps by creating an \bar{X} chart for the data in ASSEMBLY (see "Requesting Standard Tests" ) that signals a special cause of variation if an average is greater than 2.5 standard errors above the central line. The first step is to compute 2.5\sigmalimits and save both the subgroup statistics and the limits in an OUTTABLE= data set named FIRST.

   proc shewhart history=assembly;
      xchart offset * sample /
         sigmas   = 2.5
         outtable = first
         nochart ;

   proc print data=first noobs;
   run;

A listing of the data set FIRST is shown in Figure 48.12.

 
_VAR_ sample _SIGMAS_ _LIMITN_ _SUBN_ _LCLX_ _SUBX_ _MEAN_ _UCLX_ _EXLIM_
offset 1 2.5 5 5 18.1515 19.80 20.4733 22.7951  
offset 2 2.5 5 5 18.1515 17.16 20.4733 22.7951 LOWER
offset 3 2.5 5 5 18.1515 20.11 20.4733 22.7951  
offset 4 2.5 5 5 18.1515 20.89 20.4733 22.7951  
offset 5 2.5 5 5 18.1515 20.83 20.4733 22.7951  
offset 6 2.5 5 5 18.1515 18.87 20.4733 22.7951  
offset 7 2.5 5 5 18.1515 20.84 20.4733 22.7951  
offset 8 2.5 5 5 18.1515 23.33 20.4733 22.7951 UPPER
offset 9 2.5 5 5 18.1515 19.21 20.4733 22.7951  
offset 10 2.5 5 5 18.1515 20.48 20.4733 22.7951  
offset 11 2.5 5 5 18.1515 22.05 20.4733 22.7951  
offset 12 2.5 5 5 18.1515 20.02 20.4733 22.7951  
offset 13 2.5 5 5 18.1515 17.58 20.4733 22.7951 LOWER
offset 14 2.5 5 5 18.1515 19.11 20.4733 22.7951  
offset 15 2.5 5 5 18.1515 20.03 20.4733 22.7951  
offset 16 2.5 5 5 18.1515 20.56 20.4733 22.7951  
offset 17 2.5 5 5 18.1515 20.86 20.4733 22.7951  
offset 18 2.5 5 5 18.1515 21.10 20.4733 22.7951  
offset 19 2.5 5 5 18.1515 19.05 20.4733 22.7951  
offset 20 2.5 5 5 18.1515 21.76 20.4733 22.7951  
offset 21 2.5 5 5 18.1515 21.76 20.4733 22.7951  
offset 22 2.5 5 5 18.1515 20.54 20.4733 22.7951  
offset 23 2.5 5 5 18.1515 20.04 20.4733 22.7951  
offset 24 2.5 5 5 18.1515 19.94 20.4733 22.7951  
offset 25 2.5 5 5 18.1515 20.70 20.4733 22.7951  
offset 26 2.5 7 7 18.5111 21.40 20.4733 22.4356  
offset 27 2.5 7 7 18.5111 21.32 20.4733 22.4356  
offset 28 2.5 7 7 18.5111 20.03 20.4733 22.4356  
offset 29 2.5 7 7 18.5111 22.02 20.4733 22.4356  
offset 30 2.5 7 7 18.5111 21.32 20.4733 22.4356  
Figure 48.12: Listing of the Data Set FIRST

The second step is to carry out the test and create the flag variable _TESTS_.

   data first;
      set first;
      length _tests_ $ 8;
      if _subx_ > _uclx_ then substr( _tests_, 1 ) = '1';
   run;

Finally, the data set FIRST is read by the SHEWHART procedure as a TABLE= data set.

   symbol v=dot c=salmon;
   title 'Customized Analysis of Assembly Data';
   proc shewhart table=first;
      xchart offset * sample / tests      = 1
                               testlabel1 = 'Test Signaled'
                               ctests     = black
                               cconnect   = salmon
                               cinfill    = ywh
                               cframe     = vligb;
      label _subx_ = 'Average Offset in cm';
   run;

The chart is shown in Figure 48.13. Note that the variable _TESTS_ is read "as is" to flag points on the chart, and the standard tests are not applied to the data. The option TESTS=1 specifies that a point is to be labeled if the first character of _TESTS_ for the corresponding subgroup is 1. The label is specified by the TESTLABEL1= option (the default would be Test1).

tests11.gif (7248 bytes)

Figure 48.13: Customized Test

In general, you can simultaneously apply up to eight customized tests with the variable _TESTS_, which is of length 8. If two or more tests are signaled at a particular point, the label that is displayed corresponds to the test that appears first in the TESTS= list. In the preceding example, the test involves only the current subgroup. For customized tests involving patterns that span multiple subgroups, you will find it helpful to use the LAG functions described in SAS Language Reference: Dictionary.

Notes:

  1. If you provide the variable _TESTS_ in a TABLE= data set, you must also use the TESTS= option to specify which characters of _TESTS_ are to be checked.
  2. The CTESTS= and LTESTS= options specify colors and line styles for standard patterns and may not be applicable with customized tests.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.