Hi,
I came across a really strange behaviour yesterday. I've found a solution for my specific case but I've created an example for you.
fillpattern is not supported with dattrmap as mentionned by Dan
https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-dattrmap/m-p/563684
Some templates like journal2 and journal3 use pattern attribute. I haven't further investigate this approach. Feel free to add the solution with proc template if you know it.
Right now I've tried to use styleattrs statement.
For todays message I've searched and there you have the following exemple: https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Vbar-graph-Data-with-Different-color-and-...
But my problem is as follow: As soon as I add a second background color with datacolors=, only the first pattern is applied.
proc sort data=sashelp.class
out=class;
by age sex;
run;
proc sgplot data=class;
vbarbasic age / response=height
stat=mean
group=sex
groupdisplay=cluster
fillpattern;
styleattrs datafillpatterns =(r1 l1)
datacontrastcolors=(red blue)
datacolors =(yellow pink);
run;
The workaround I used is to plot twice the graph: once with just the background and once with the pattern combined with the nofill option.
But my first thought here is that it is a bug. How about you?
You need a special option ATTRPRIORITY=NONE to make it happen.
proc sort data=sashelp.class
out=class;
by age sex;
run;
ods graphics/attrpriority=none;
proc sgplot data=class;
vbarbasic age / response=height
stat=mean
group=sex
groupdisplay=cluster
fillpattern;
styleattrs datafillpatterns =(r1 l1)
datacontrastcolors=(red blue)
datacolors =(yellow pink);
run;
You need a special option ATTRPRIORITY=NONE to make it happen.
proc sort data=sashelp.class
out=class;
by age sex;
run;
ods graphics/attrpriority=none;
proc sgplot data=class;
vbarbasic age / response=height
stat=mean
group=sex
groupdisplay=cluster
fillpattern;
styleattrs datafillpatterns =(r1 l1)
datacontrastcolors=(red blue)
datacolors =(yellow pink);
run;
Thank you.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.