Data visualization with SAS programming

Bar Chart fill pattern GTL won't work

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Bar Chart fill pattern GTL won't work

data test;
   input x $ y grp $;
   datalines;
1 5 A
1 8 B
2 6 A
2 9 B
;
run;

proc sort data = test;
	by x grp y;
run;


ods path(prepend) work.templat(update);



proc template;
  define statgraph testtemp;


	/* Begin the graph template */
	begingraph / border = false designwidth = 800px designheight = 400px;


	  /* Start the graph area and define the options */
	  layout overlay / /* X axis */
					   xaxisopts = (label = "x"
									display = (label tickvalues)
									type = discrete)
					   /* Y axis */
					   yaxisopts = (label = "y" linearopts=( viewmin=0 viewmax =10));

		/* Bar plot */
		barchart category=x response=y / name = "bar"
													group = grp
													groupdisplay = cluster
													display = (outline fillpattern)
													outlineattrs=(color=black) fillpatternattrs=(color=grey /*pattern =l1*/)  barwidth=0.25;

		/* Legend */
		discretelegend "bar" / title = "Group: "
							   valueattrs = (family = "arial")
							   location = outside
							   halign = center
							   valign = bottom;

	  endlayout;
	endgraph;
  end;
run;

/*Open destination*/;
ods listing close;
ods rtf file = "xxx" /*style=tfl*/;
ods graphics / reset imagefmt = png;

proc sgrender 
	data=test 
	template=testtemp;
run;

ods rtf close;
ods listing;

Hi,

 

I have attached a simplified version of what I am trying to do. I want a black outline and the fill pattern to change along with the group variable. From what I can see on the SAS GTL reference this is possible, so I'm not sure what I am missing. 

 

Unless I specify a particular pattern I cannot get a fill pattern to show up(with or without an outline), and of course having the same fill pattern for both groups is not really useful for me. Any help would be appreicated as I'm not really sure what the issue is. Also I am using SAS 9.4 M1.

 

Thanks


Accepted Solutions
Solution
‎02-24-2017 05:17 AM
Grand Advisor
Posts: 17,325

Re: Bar Chart fill pattern GTL won't work

There's a restriction under FILLPATTERATTRS in the docs:

 

The only styles that are delivered by SAS that support fill patterns are JOURNAL2, JOURNAL3, and MONOCHROMEPRINTER. If any other such style is in effect and this option uses style-element in its specification, then this option is ignored.

 

I'm not sure if changing the style would help but it's easy to try. 

View solution in original post


All Replies
Solution
‎02-24-2017 05:17 AM
Grand Advisor
Posts: 17,325

Re: Bar Chart fill pattern GTL won't work

There's a restriction under FILLPATTERATTRS in the docs:

 

The only styles that are delivered by SAS that support fill patterns are JOURNAL2, JOURNAL3, and MONOCHROMEPRINTER. If any other such style is in effect and this option uses style-element in its specification, then this option is ignored.

 

I'm not sure if changing the style would help but it's easy to try. 

Occasional Contributor
Posts: 6

Re: Bar Chart fill pattern GTL won't work

Thank you very much, I did not notice this in the docs but this has solved it.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 155 views
  • 0 likes
  • 2 in conversation