Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Graphical Enhancements

Using Switch Variables

See SHWSVAR in the SAS/QC Sample Library

As an alternative to reading a LIMITS= data set and using a WHERE statement, you can provide two special switch variables named _COMP_ and _DISP_ in the input data set. The rules for using these variables are as follows:

The following statements illustrate how the switch variables _COMP_ and _DISP_ can be used with the bottle production data:

   data bottles;
      length _comp_ _disp_ $ 1;
      set bottles;
      if      day  = '13JAN94'D then _comp_ = 'n';
      else if day  = '14JAN94'D then _comp_ = 'n';
      else if day <= '31JAN94'D then _comp_ = 'y';
      else                           _comp_ = 'n';
      if      day <= '31JAN94'D then _disp_ = 'n';
      else                           _disp_ = 'y';
   run;

   title 'Analysis of February Production';
   proc shewhart data=bottles;
      pchart ncracks * day / subgroupn = nbottles
                             nolegend
                             nohlabel;
      label ncracks = 'Proportion With Cracks';
   run;

The chart is identical to the chart in Figure 47.35.

In general, switch variables are more versatile than WHERE statements in applications where subgroups are simultaneously selected for computation and display. Switch variables also provide a permanent record of which subgroups were selected. The WHERE statement does not alter the input data set; it simply restricts the observations that are read; consequently, the WHERE statement can be more efficient than switch variables for processing large data sets.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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