Desktop productivity for business analysts and programmers

Change fill colours on a stacked bar chart (SGPLOT)

Reply
Frequent Contributor
Posts: 130

Change fill colours on a stacked bar chart (SGPLOT)

Hi All,

 

I have created a stacked bar graph and I need to change the colours of the bars after the 25th June 2018.

 

This is the code I use to create the chart.

 

PROC SGPLOT data=work.MERGETEST noborder;
Title "Test";
VBAR EVENT_DT / RESPONSE=COUNT GROUP=CONTACT;
 yaxis display=(noline noticks) grid values=(0 to 100000 by 1000) offsetmin=0
		label='Count' ;
	inset 'Change started on the 25 June 2018' / position= topright border;
RUN;

I have used the following to change the fill colour in a single bar

 

Data Attrmap;
	Retain id "myid";
	input value $ fillcolor $8.;
	datalines;
	0 VIBG
	1 BIBG
	;
run;

 

and use dattrmap=attrmap  attrid=myid in the SGPLOT.

 

How do I now change it to colour the stacked bar chart 

 

Cheers

 

Dean

Super User
Super User
Posts: 9,866

Re: Change fill colours on a stacked bar chart (SGPLOT)

Can you not do two plots with overlay?  I.e. plot all values < 25jun and give those a style color, then plot all values > 25jun and give those a style color different to the first?  That would be the quickest way I can think of.  The other way would be to use groups.  So in your data assign < 25jun as group1, > 25jun as group 2, then use the group= options in the plot.  The best reference for graphing is here:

http://blogs.sas.com/content/graphicallyspeaking/

 

And please avoid coding all in uppercase, it really makes code hard to read.

Ask a Question
Discussion stats
  • 1 reply
  • 81 views
  • 0 likes
  • 2 in conversation