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.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.