BookmarkSubscribeRSS Feed
Venkat4
Quartz | Level 8

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;

 

 

 

1 REPLY 1
ballardw
Super User

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?

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1217 views
  • 0 likes
  • 2 in conversation