Data visualization with SAS programming

Fill patterns in Highlow plot

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Fill patterns in Highlow plot

Hello everyone,

 

I'm trying to create a horizontal bar graph with median and 95% CI using highlow plot, since each bar represents a group I wanted to fill the bars with different patterns keeping the same color. So, I tried doing this by creating a template and by creating data attribute maps and both didnt work for patterns. However, the graph seems to pick the colors from template/attrmap. Is there any way to do this.

 

SAS version: SAS 9.4_M4

 

Thanks

 

 

 


Accepted Solutions
Solution
‎04-27-2017 09:17 AM
SAS Super FREQ
Posts: 1,078

Re: Fill patterns in Highlow plot

Fill patterns for HighLow plot are NOT currently supported.  Fill patterns will be supported for most plot types with fill attribute starting with SAS 9.40M5 to be released later this year.  In the meantime, you can refer to this recent SASGF 2017 paper by Amos Shu on how you can work around this.

View solution in original post


All Replies
Grand Advisor
Posts: 10,192

Re: Fill patterns in Highlow plot

Insufficient information. As a minimum we would need your template, attribut set and actual graph procedure call. Best would also provide an example of the data used for the plots.

You can use Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

New Contributor
Posts: 3

Re: Fill patterns in Highlow plot

[ Edited ]

Thanks Ballard, for the quick reply. Below is the sample code and attached are plots using template and attribute map. I was expecting to see a pattern "L2" on 2nd and 4th bars.

 

 

proc template;
   define style mypatterns;
   parent=styles.htmlblue;
	style graph from graph / 
	attrpriority="None";
   style GraphBar from GraphComponent /                                 
         displayopts = "fill outline fillpattern";
      style GraphData1 from GraphData1 /                                      
            fillpattern = "E";                                                  
      style GraphData2 from GraphData2 /
            fillpattern = "L2";                                                  
     end;
run;

data attrmap;
length fillpattern $4;
	id='Make'; value='Acura'; fillcolor='Red'; fillpattern='E';output;
	id='Make'; value='Audi'; fillcolor='Red'; fillpattern='L2';output;
	id='Make'; value='BMW'; fillcolor='Red'; fillpattern='E';output;
	id='Make'; value='Buick'; fillcolor='Red'; fillpattern='L2';output;
run;


proc means data=sashelp.cars;
	by make;
	var mpg_city;
	output out=means mean=mean min=min max=max;
	where make in ('Acura' 'Audi' 'BMW' 'Buick');
run;

options nonumber nodate orientation=landscape;
ods graphics /reset noscale width=8in height=5in imagename="Plot using Template";
ods listing gpath="H:\Test" style=mypatterns;

title1 " ";
footnote1 " ";
proc sgplot data=means noautolegend;
	highlow y=make high=max low=min / type=bar barwidth=0.7 fillattrs=(color=yellow) LINEATTRS=(pattern=solid ) dataskin=crisp group=make;
	scatter y=make x=mean / markerattrs=(symbol=starfilled size=8 color=black);
run;

options nonumber nodate orientation=landscape;
ods graphics /reset noscale width=8in height=5in imagename="Plot using Attrib Map";
ods listing gpath="H:\Test" style=mypatterns;

title1 " ";
footnote1 " ";
proc sgplot data=means noautolegend dattrmap=attrmap;
	highlow y=make high=max low=min / type=bar barwidth=0.7 /*fillattrs=(color=yellow)*/ LINEATTRS=(pattern=solid ) dataskin=crisp group=make attrid=Make;
	scatter y=make x=mean / markerattrs=(symbol=starfilled size=8 color=black);
run;

 

Thanks

Attachment
Attachment
Solution
‎04-27-2017 09:17 AM
SAS Super FREQ
Posts: 1,078

Re: Fill patterns in Highlow plot

Fill patterns for HighLow plot are NOT currently supported.  Fill patterns will be supported for most plot types with fill attribute starting with SAS 9.40M5 to be released later this year.  In the meantime, you can refer to this recent SASGF 2017 paper by Amos Shu on how you can work around this.

New Contributor
Posts: 3

Re: Fill patterns in Highlow plot

Hi Sanjay,

 

Thanks for providing the reference. I was able to produce the graph I needed with "barchart" as suggested in the paper. 

 

Thanks

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 153 views
  • 1 like
  • 3 in conversation