BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi All,

 

I'm a fan of PROC SHEWHART, but I've never liked how it highlights trends, so I usually end up coding my own trend detection.  Wondering if I'm missing something.

 

Below data and code is from SAS/QC docs.  I modified the data so that instead of a trend of 5 increasing values, there is a trend of 7 increasing values.

data Assembly;
  length System $ 1 comment $ 16;
  label Sample = 'Sample Number';
  input System Sample OffsetX OffsetR OffsetN comment $16. ;
  if sample=19 then offsetX=21.5; *make a trend of 7 increasing, sample 14-20;
datalines;
T 1 19.80 3.8 5
T 2 17.16 8.3 5
T 3 20.11 6.7 5
T 4 20.89 5.5 5
T 5 20.83 2.3 5
T 6 18.87 2.6 5
T 7 20.84 2.3 5
T 8 23.33 5.7 5 New Tool
T 9 19.21 3.5 5
T 10 20.48 3.2 5
T 11 22.05 4.7 5
T 12 20.02 6.7 5
T 13 17.58 2.0 5
T 14 19.11 5.7 5
T 15 20.03 4.1 5
R 16 20.56 3.7 5 Changed System
R 17 20.86 3.3 5
R 18 21.10 5.6 5 Reset Tool
R 19 19.05 2.7 5
R 20 21.76 2.8 5
R 21 21.76 6.4 5
R 22 20.54 4.8 5
R 23 20.04 8.2 5
R 24 19.94 8.8 5
R 25 20.70 5.1 5
Q 26 21.40 12.1 7 Bad Reading
Q 27 21.32 3.2 7
Q 28 20.03 5.2 7 New Gauge
Q 29 22.02 5.9 7
Q 30 21.32 4.3 7
;



title 'Analysis of Assembly Data';
proc shewhart history=Assembly;
xrchart Offset * Sample / 
  nochart2
  outtable=ShewResults
  mu0 = 20
  sigma0 = 2.24
  limitn = 5
  alln
  tests = 3
  vaxis = 16 to 26 by 2
  split = '/';
  label OffsetX = 'Avg Offset in cm/Range'
;
run;

proc print data=shewresults;
  var sample _subx_ _tests_;
run;
title2;

Two things about the trend detection bother me.

 

1. There is a trend of 7 increasing values, but only the first 5 are highlighted in the chart.  If the trend continues beyond the limit, I would think the whole trend should be highlighted.

 

SPC.PNG

2. The output dataset ShewResults flags trends, but it only flags the one subgroup where the trend of 5 increasing in a row was detected (Sample 18).  It would be much more useful if it flagged Sample 14-17 as well, and also 19-20.  That is, I think it would be better if the _TESTS_ variable flagged all subgroups that are part of the trend.

 

Sample    _SUBX_    _TESTS_

   1       19.80
   2       17.16
   3       20.11
   4       20.89
   5       20.83
   6       18.87
   7       20.84
   8       23.33
   9       19.21
  10       20.48
  11       22.05
  12       20.02
  13       17.58
  14       19.11
  15       20.03
  16       20.56
  17       20.86
  18       21.10       3
  19       21.50
  20       21.76
  21       21.76
  22       20.54
  23       20.04
  24       19.94
  25       20.70
  26       21.40
  27       21.32
  28       20.03
  29       22.02
  30       21.32

Because of these limitations, I usually just code my own trend detection.  But before I do that again, wanted to make sure I'm not missing an easy way to get what I want from directly out of Shewhart.   Mostly want I want is an output dataset , with the subgroups 14-20 flagged for being part of a trend.

 

Thanks,

--Q.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I think the TESTOVERLAP option does what you want.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I think the TESTOVERLAP option does what you want.

--
Paige Miller
Quentin
Super User

Thanks @PaigeMiller .  Indeed, Testoverlap does solve the first problem.  It extends the trend so that the full trend is highlighted.  

 

I still wish there was a way to make the output data to flag the samples at the beginning of the trend (i.e. samples 14-17).  But since I know the number of number of samples in the trend rule, it shouldn't be that bad for me to count back to the beginning of the trend. And probably better than counting my own trends.

 

proc shewhart history=Assembly;
xrchart Offset * Sample / 
  nochart2
  outtable=ShewResults
  mu0 = 20
  sigma0 = 2.24
  limitn = 5
  alln
  tests = 3
  testoverlap
  vaxis = 16 to 26 by 2
  split = '/';
  label OffsetX = 'Avg Offset in cm/Range' 
;
run;


Sample    _SUBX_    _TESTS_

   1       19.80
   2       17.16
   3       20.11
   4       20.89
   5       20.83
   6       18.87
   7       20.84
   8       23.33
   9       19.21
  10       20.48
  11       22.05
  12       20.02
  13       17.58
  14       19.11
  15       20.03
  16       20.56
  17       20.86
  18       21.10       3
  19       21.50       3
  20       21.76       3
  21       21.76
  22       20.54
  23       20.04
  24       19.94
  25       20.70
  26       21.40
  27       21.32
  28       20.03
  29       22.02
  30       21.32
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 561 views
  • 1 like
  • 2 in conversation