Data visualization with SAS programming

Proc Sgplot with band unable to fill in the colors just under the data line, not under the refline

Reply
Contributor
Posts: 41

Proc Sgplot with band unable to fill in the colors just under the data line, not under the refline

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;

 

 

 

Super User
Posts: 13,084

Re: Proc Sgplot with band unable to fill in the colors just under the data line, not under the refli

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?

Ask a Question
Discussion stats
  • 1 reply
  • 74 views
  • 0 likes
  • 2 in conversation