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

I wanted to set the y-axis of a control chart to always run from 0 to 100%. However, Proc Shewhart seems to only allow the data range in y-axis. Is there anyway I can set the y-axis to always run from 0 to 100%? 

 

Here are two options I tried: 

 

ods graphics off; 
title 'ZZZ'; 
symbol v=dot color=darkblue h=1.75; 
proc shewhart data=percentages;
	xchart a*b/ interval = month climits=red nolimitlabel nolegend vformat = percent10. vaxis = (0 to 1 by 0.1);
	label a='XXX' b='YYY'; 
run; 

ods graphics off;
title 'ZZZ'; /*TITLE TO THE CHART*/
axis1 order = (0 to 1 by 0.1)
label=("XXX");
axis2 label = ("YYY"); 
symbol v=dot color=darkblue h=1.75; /*SYMBOL TYPE, COLOR AND DIAMETER*/
proc shewhart data=percentages;
	xchart a*b/ vaxis = axis1 haxis=axis2 interval = month climits=red nolimitlabel nolegend vformat=percent10.; 
run;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Ok, I think I have discovered the problem. 

 

The lower control limit is negative, so the axis has to have a negative lower limit. However, if your code has

 

vaxis=(-0.1 to 1 by 0.1)

it will work, even if that's not really what you want.

 

It may be possible to use PCHART which can't have lower limits below 0%, but your data is not set up to allow PCHART to work, you'd probably have to go back to the original data (not the summarized data) to make PCHART work.

--
Paige Miller

View solution in original post

11 REPLIES 11
PaigeMiller
Diamond | Level 26

What happened when you tried? Was there an error message or warning in the log? Was a plot actually produced?

 

What values does the variable A (on the y-axis) contain?

 

Also, my memory is that you can't have an axis whose range is smaller than the data (unless you CLIP the data), but you should be able to create an axis whose range is larger than the data.

--
Paige Miller
guaguncher
Obsidian | Level 7

This is what I get when I run the code. The range goes from what seems to be (negative) 10% to 50%, which is the range of the data, although there are no negative values in the data. Variable A (y axis) contains percentages/proportions, and variable B (x axis) contains months. I wanted the y axis to run from 0 to 100. shewha89.png

PaigeMiller
Diamond | Level 26

Was there an error message or warning in the log? 

--
Paige Miller
guaguncher
Obsidian | Level 7

I received the following warning: 

 

WARNING: For process variable a the VAXIS= values specified do not cover the data range.
WARNING: Default scaling is substituted
PaigeMiller
Diamond | Level 26

That should make you concerned. Please run the following code and provide the calculated minimum and maximum values of A.

 

proc means data=percentages min max;
    var a;
    format a;
run;
--
Paige Miller
guaguncher
Obsidian | Level 7

This seems about right, the data ranges from 0 to 0.4.

Capture.PNG

PaigeMiller
Diamond | Level 26

Very odd.

 

How large is this data set PERCENTAGES? If it is not too large, can you attach it here? (Don't bother if it is huge...)

--
Paige Miller
guaguncher
Obsidian | Level 7

It is a small dataset, I have attached it. 

PaigeMiller
Diamond | Level 26

Ok, I think I have discovered the problem. 

 

The lower control limit is negative, so the axis has to have a negative lower limit. However, if your code has

 

vaxis=(-0.1 to 1 by 0.1)

it will work, even if that's not really what you want.

 

It may be possible to use PCHART which can't have lower limits below 0%, but your data is not set up to allow PCHART to work, you'd probably have to go back to the original data (not the summarized data) to make PCHART work.

--
Paige Miller
guaguncher
Obsidian | Level 7

Thank you! This does help a lot. 

guaguncher
Obsidian | Level 7

Just as an update tick marks and percentages below 0 on the y-axis can  be suppressed by specifying  values for axis and hiding the tick marks:

 

ods graphics off;
title 'ZZZ';
axis1 order = (-.1 to 1 by 0.1) value=(' ' '0%' '10%' '20%' '30%' '40%' '50%' '60%' '70%' '80%' '90%' '100%') 
      label=("XXX") major=none;
axis2 label = ("YYY"); 
symbol v=dot color=darkblue h=1.75;
proc shewhart data=percentages2;
  xchart a*b/ vaxis = axis1 haxis=axis2 interval = month climits=red nolimitlabel nolegend vformat=percent10.; 
run;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 2002 views
  • 1 like
  • 2 in conversation