BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

Ksharp_0-1720923633647.png

 

 

View solution in original post

2 REPLIES 2
Ksharp
Super User

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;

Ksharp_0-1720923633647.png

 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

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.

 

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
  • 2 replies
  • 663 views
  • 1 like
  • 2 in conversation