BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhr-q
Obsidian | Level 7

I need to add a horizontal reference line at 90% to represent my target in the p-chart. When I put  href=0.9 in my code I got the following warning

"WARNING: Numeric href= values are incompatible with a character subgroup variable; HREF= lines are not displayed."

The warning indicates that the href value is not compatible because the subgroup variable, quarter, is treated as a character data type.

How to include the target line?

 

Here is my code:

proc shewhart data=tmp2;
pchart yes_answer1*quarter/ markers  subgroupn = total_count1
nohlabel   Href=0.9;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ
HREF=values

draws reference lines perpendicular to the horizontal (subgroup) axis on the primary chart.

 

VREF=value-list

draws reference lines perpendicular to the vertical axis on the primary chart.

 

Koen

View solution in original post

11 REPLIES 11
sbxkoenk
SAS Super FREQ

Just turn your quarter variable into something numeric.
Like here :

data Battery;
   length lot $6;
   input lot nFailed Sampsize @@;
   label nFailed  = 'Number Failed'
         lot      = 'Lot Number'
         Sampsize = 'Number Sampled';
   Quarter_num = yyq(scan(lot,1,'Q'),scan(lot,2,'Q'));
   datalines;
2015Q1  6  151     2015Q2  5  142     2015Q3  6  145
2015Q4  9  149     2016Q1  3  150     2016Q2  0  156
2016Q3  4  150     2016Q4  9  158     2017Q1  4  152
2017Q2  0  162     2017Q3  9  140     2017Q4  7  161
2018Q1  6  154     2018Q2  1  144     2018Q3  5  154
2018Q4  3  151     2019Q1  8  148     2019Q2  2  143
2019Q3  4  150     2019Q4  4  147     2020Q1  0  150
2020Q2  2  154     2020Q3  8  149     2020Q4  3  160
2021Q1  9  153
;

/* The variable nFailed contains the number of battery failures, */
/* the variable Lot contains the lot number,                     */
/* and the variable Sampsize contains the lot sample size.       */
/* The following statements request a p chart for this data:     */
ods graphics off;
title 'Proportion of Battery Failures';
proc shewhart data=Battery;
   pchart nFailed*Lot / subgroupn = Sampsize
                      /*turnhlabels*/ nohlabel href=20400 21200 21800
                        font      = 'Lucida Console'
                        outlimits = Batlim;
   label nFailed = 'Proportion Failed';
run;

ods graphics off;
title 'Proportion of Battery Failures';
proc shewhart data=Battery;
   pchart nFailed*Quarter_num / /*totpanels=40*/ npanelpos=2500 
                        subgroupn = Sampsize
                      /*turnhlabels*/ nohlabel href=20400 21200 21800
                        font      = 'Lucida Console'
                        outlimits = Batlim;
   label nFailed = 'Proportion Failed';
   format Quarter_num yyQ.;
run;
/* end of program */

Koen

sbxkoenk
SAS Super FREQ
HREF=values

draws reference lines perpendicular to the horizontal (subgroup) axis on the primary chart.

 

VREF=value-list

draws reference lines perpendicular to the vertical axis on the primary chart.

 

Koen

Quentin
Super User

@sbxkoenk wrote:
HREF=values

draws reference lines perpendicular to the horizontal (subgroup) axis on the primary chart.

 

VREF=value-list

draws reference lines perpendicular to the vertical axis on the primary chart.

 

Koen


This always feels backwards to me.  First instinct is that HREF means "horizontal reference line."  I'm sure the developer had a good reason for doing it this way... Luckily even though I can't remember which to use, there are only two options to try.  : )

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Quentin
Super User

Hi @bhr-q thank you for taking the time to mark an accepted solution, as that helps the community.  In this case, I would recommend you change the accepted solution to be @sbxkoenk's answer where they provided the answer (which I quoted in my message).  My answer wasn't really the solution, it was more a note of sympathy that I often make the same mistake.  I believe if you click somewhere on my answer, there will be a button that allows you to say "this is NOT the solution", and after saving that change, you should then be able to pick Koen's answer as the real solution.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
bhr-q
Obsidian | Level 7
I agree with you, I actually tried to do that with right click on your answer but couldn't find that. if there is anyway let me know to do that.

Thank you so much all of you for your help and sorry for the mistake.
sbxkoenk
SAS Super FREQ

@bhr-q wrote:
I agree with you, I actually tried to do that with right click on your answer but couldn't find that. if there is anyway let me know to do that.
Thank you so much all of you for your help and sorry for the mistake.

You should not look too hard (to change solutions).

For me, it's okay. It's fine as it is. Most important thing is that your original question is solved!
Moreover, the addition of @Quentin (on the counter-intuitive aspect) is also relevant. Many people will recognize themselves in it. 😉

 

Koen

Quentin
Super User

@bhr-q wrote:
I agree with you, I actually tried to do that with right click on your answer but couldn't find that. if there is anyway let me know to do that.

Thank you so much all of you for your help and sorry for the mistake.

If you still see the hamburger menu (three horizontal lines)  next to the post, I think you would click that and it should be in that menu.

Quentin_0-1715292246269.png

 

But it's possible that the correct answer locks after a few hours, so you might not be able to change it now.  If that's the case, no worries. I'm happy to take @sbxkoenk 's points for an accepted solution. : )

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
bhr-q
Obsidian | Level 7

 

Thank you for your answer; I ran the code below but couldn't get the ref line.

data tmp2_numeric; set tmp2; quarter_num = yyq(scan (quarter, 1, 'Q'), scan (quarter, 2, 'Q')); run; proc shewhart data=tmp2_numeric; pchart yes_answer1*quarter_num/ subgroupn=total_count1 nohlabel href=0.9; label quarter_num= 'Quarter'; label yes_answer1 = 'Proportion of pts counselled'; format quarter_num yyQ.; run;

 

sbxkoenk
SAS Super FREQ

I cannot see the LOG of your code after submission, but 2 things might have gone wrong here:

1. are your quarters (the character version) strings like "2022Q2" (yyyy for the year then a letter Q and then the quarter number)?

2. you need vref=0.9 instead of href=0.9.  I do not see how 0.9 can be a quarter-indication, but 0.9 can be a proportion. On the VREF= option, you specify vertical axis values, on the HREF= option you specify horizontal axis values. Like @Quentin , you might be confused about this 😉.

 

Koen

bhr-q
Obsidian | Level 7
Thank you for your answer, I could have a target line using VREF now.
Just wondering when I consider:
Vref=0.90 CVREF=green;
I expected to have a green line, but the color doesn't change.
Quentin
Super User

Unfortunately, looks like cvref= and similar options only apply if you are using SAS/GRAPH to generate the output graph.  They don't apply to graphs generated with ODS graphics.  I think to get the refline to be a different color, you will have to look at modifying the ODS style template.

 

Another option I have used is to use PROC SHEWHART to calculate the process limits etc, then output that data to a dataset and use SGPLOT to make the graph.  In SGPLOT there are options to directly control the color of lines, markers, etc, without having to muck with a style template.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 11 replies
  • 587 views
  • 13 likes
  • 3 in conversation