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-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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.

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
  • 1 reply
  • 928 views
  • 0 likes
  • 2 in conversation