BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ram21
Calcite | Level 5

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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

4 REPLIES 4
ballardw
Super User

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.

Ram21
Calcite | Level 5

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


Plot using Attrib Map1.pngPlot using Template1.png
Jay54
Meteorite | Level 14

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.

Ram21
Calcite | Level 5

Hi Sanjay,

 

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

 

Thanks

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 2170 views
  • 1 like
  • 3 in conversation