Here is the code I used to create charts with multiple limits.
It first requires some sample data. I started with the sample data set Flange and added in two columns :Plant & Machine. These represent the different processes I require in my code. I then replicated the existing 30 observations to create four distinct sets of results;
Plant: ABC, Machine: Red
Plant: ABC, Machine: Blue
Plant: XYZ, Machine: Red
Plant: XYZ, Machine: Blue
I then varied the FlwidthX values by a random value in three of the four sets to ensure I was getting 4 sets of limits.
/**
**Step 1: Create Limits by Plant, Machine and _phase_
**/
PROC SQL; /* 1-1 sort data by different charts and phase */
Create Table Flange AS
Select t1.Plant, t1.Machine, t1._phase_, t1.Day, t1.Sample, t1.FlwidthX, t1.FlwidthN
From Flange2 as t1
Order by Plant, Machine, _phase_, Sample;
;
%_eg_conditional_dropds(WORK.Flange2);
proc shewhart data=Flange ; /* 1-2 create the limits table*/
xchart FlwidthX*Sample /
nochart
OUTLIMITS=testlimits
;
BY Plant Machine _phase_;
run;
PROC SQL; /* 1-3 re-label the limits table */
Create table testlimits2 AS
Select t1.Plant, t1.Machine, t1._phase_ as _index_
, t1._VAR_, t1._SUBGRP_, t1._TYPE_, t1._LIMITN_
, t1._ALPHA_, t1._SIGMAS_, t1._LCLX_, t1._MEAN_
, t1._UCLX_, t1._LCLR_, t1._R_, t1._UCLR_, t1._STDDEV_
From testlimits as t1
Order by t1.Plant, t1.Machine, _index_, t1._SUBGRP_;
;
%_eg_conditional_dropds(WORK.testlimits);
/**
** Step 2: Create the XChart with multiple limits
**/
PROC SORT DATA=WORK.FLANGE /* 2-1 Re-sort the data table */
OUT=WORK.FLANGE3
;
BY Plant Machine Sample;
RUN;
%_eg_conditional_dropds(WORK.FLANGE);
proc shewhart data=Flange3 limits=testlimits2; /* 2-2 Create charts */
xchart FlwidthX*Sample /
readphase = all
readindex = all
;
BY Plant Machine;
run;
%_eg_conditional_dropds(WORK.Flange3);
%_eg_conditional_dropds(WORK.testlimits2);
I will never get the last 3 hours of my life back writing something so convoluted that should be a fundamental option within the SHEWHART procedures.
John