BookmarkSubscribeRSS Feed
DME790
Pyrite | Level 9

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

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2342 views
  • 0 likes
  • 2 in conversation