Hi!
I'm trying to reproduce the colors in the Shewhart IRChart like it is shown bellow.
I've succeded doing the chart, changing the upper and lower limits, changing the labels, changing the color of the zone between the UCL and LCL, but I want 3 zones, with 3 colors... I've tried with interpol statement, with pattern statement, and here's my code... I can't give you the datas that comes with it, unfortunately...
/******Here's the control limits I used***************/
data limcarte1;
_var_="diff";
_subgrp_="ID";
_type_="STANDARD";
_alpha_=0.002699796;
_sigmas_=3;
_limitn_=2;/*****sous groupe pour la partie moving range**/
_LCLI_=-0.66;
_UCLI_=0.66;
_Mean_=0;
_LCLR_=0;
_R_=1;
_UCLR_=3;
_stddev_=0.22;
run;
/********** here's the code**************/
title "essais irchart";
/****/
ods graphics off;
ods html close;
ods listing;
options odsstyle=default;
/****/
proc Shewhart data=cartetest1 limits=limcarte1 ;
symbol v=dot;
irchart diff*id / haxis=0 to 45 by 5
vaxis=-1.1 to 1 by 0.22
limitn=2
nochart2 /* enlève la 2e charte de R*/
zones
lzones=2 /*traits pointillés*/
cinfill=orange
ltmplot=histogram
ltmargin=25
nohlabel
cframe=white /*Couleur à l'extérieur de la zone limite*/
/*vref= 0.33 pour mettre des lignes horizontales*/
UCLLABEL='0.66'
LCLLABEL='-0.66'
xsymbol='0'
LSL=-0.44
zonelabels
zonevalpos=1
tests=1 2 3 5;
run;
I've been searching for more than two days... Can you help me with it please? Thank you so much!
here's what I want:
Here's what I have.... 😕
Marie-Christine Bélanger
Secteur statistique et traitement des données
Direction du laboratoire des chaussées Ministère des Transports, de la Mobilité durable et l’Électrification des transports
Hi Marie-Christine,
PROC SHEWHART does not provide an option to fill the zones with different colors, but you can accomplish this by using ODS Graphics with a modified ODS style. The following statements produce the chart that is shown below:
data foo;
do group = 1 to 40;
x = rannor(123);
output;
end;
run;
proc template;
define style Styles.Custom;
parent = Styles.HTMLBlue;
Class GraphColors /
"gzonea" = cxEB6F09
"gzoneb" = cxFFFF68
"gzonec" = cx4A8E5A
;
end;
run;
ods listing style=Custom;
ods graphics on;
proc shewhart data=foo;
irchart x * group /
zonelabels
markers
nochart2
ltmplot=histogram
odstitle="essais irchart"
;
run;
Note that not all the PROC SHEWHART options that apply to traditional graphics output (ODS Graphics disabled), e.g. LZONES=, apply when ODS Graphics is enabled.
Hi! Thanks for your quick answer! Althought I have the same graphic with your code, the colors stay the same (blue)... I was told that it could maybe be caused by my version of SAS... (9.3). To get colors in a graphic, I had to put these code lines before proc Shewhart:
/****/
ods graphics off;
ods html close;
ods listing;
options odsstyle=default;
/****/
What should I do to combine both?
Thank you very much!!
Marie-Christine
@bemariec wrote:
Hi! Thanks for your quick answer! Althought I have the same graphic with your code, the colors stay the same (blue)... I was told that it could maybe be caused by my version of SAS... (9.3). To get colors in a graphic, I had to put these code lines before proc Shewhart:
/****/
ods graphics off;
ods html close;
ods listing;
options odsstyle=default;
/****/
You don't show where you set the style Custom as created for the solution. Did you try ods listing style=Custom; instead of
ods listing;
options odsstyle=default;
Hi!
I've recopy exactly the same code as you, just to try again and here's the warning message (I've also tried with my collegue's version (9,4) and it is an error message instead of warning...) :
49 ods listing style=Custom;
WARNING: Could not restore referenced object: HTMLBlue.
WARNING: Could not find parent template: HTMLBlue.
50 ods graphics on;
I've been working with SAS (and programing language in general) for almost 3 weeks now, so I still struggle with basics 😕 .Thanks for your help and patience! 🙂
I've joined the complete log message!!
Thanks!
The ODS style elements that enable you to control the fill colors for the zones independently were added for SAS 9.4. I don't know of a way to produce a control chart with different colors in the zones in an earlier release.
From your log: SAS/STAT 12 => SAS 9.2 of some flavor I believe and nearly 10 years old depending on specific version. So there have been many changes to the graphics options and supplied ODS styles since.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.