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 2025: Call for Content

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!

Submit your idea!

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