I am creating a Proc Shewhart type of Control charts via Sgplot and some call execute macro (we don't have SAS/QC license). It works nicely, but I wanted the band filled in just above the high risk with red color, above medium risk with light red, then yellow and green etc. Don't worry much about the color, but I wanted the color to be filled in just under the actual data line, not entirely under the two std or other refline. I used to do this 3-4 years ago, but forgot how I got that and didn't save my code.
Can someone please help?
proc sgplot data=vwork.t3CTRLBusArea (where = (Business_area="&BusinessArea.") noautolegend nocycleattrs;
band x=Date upper=Totcases lower=&TwoSDPlusAvgTotCasesBusArea. / fillattrs=(color=red);
band x=Date upper=&TwoSDPlusAvgTotCasesBusArea. lower=&OneSDPlusAvgTotCasesBusArea. / fillattrs=(color=lightred);
band x=Date upper=&OneSDPlusAvgTotCasesBusArea. lower=&AvgTotCasesBusArea. / fillattrs=(color=yellow);
band x=Date upper=&OneSDMinusAvgTotCasesBusArea. lower=0 / fillattrs=(color=green);
series x=Date Y=TotCases / group=Business_Area lineattrs=Graphdata1 (thickness=1mm) ;
refline &AvgTotCasesBusArea. /axis=y label=("AVG") lineattrs=(color=green pattern=dash);
refline &OneSDMinusAvgTotCasesBusArea. /axis=y label=("LOW RISK") lineattrs=(color=blue pattern=dash);
refline &OneSDPlusAvgTotCasesBusArea. /axis=y label=("MED RISK") lineattrs=(color=lightred pattern=dash);
refline &TwoSDPlusAvgTotCasesBusArea. /axis=y label=("HIGH RISK") lineattrs=(color=darkred);
xaxis display=(nolabel);
yaxis label="Total xxxx";
run;
Without data it is a challenge to make specific recommendations.
Note that changing the order of the band statements may make a difference in appearance.
Are your values for &TwoSDPlusAvgTotCasesBusArea explicit values or variables in the data? How do we know what is 'high risk', 'medium risk' etc?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.