Data visualization with SAS programming

Colors in Sgplot stacked bar chart

Reply
N/A
Posts: 1

Colors in Sgplot stacked bar chart

Hello,

I'm currently trying to find a way to customize colors in a stacked bar chart. The colors are currently blue/red.

Here is an example of my code:

proc sort data=t.indic_f;

by A;

run;

proc freq data=t.indic_f noprint;

table RETARD_PAT/out=test3;

by A;

run;

proc sgplot data=test3;

vbar A / response=Percent group=RETARD_PAT groupdisplay=stack;

xaxis discreteorder=data;

yaxis grid values=(0 to 100 by 10) label="Percentage of Total with Group";

format RETARD_PAT retards.;

run;

I've done a lot of research to no avail... Thanks!lot

Grand Advisor
Posts: 9,315

Re: Colors in Sgplot stacked bar chart

You should post it at GRAPH forum ,not this forum .

Grand Advisor
Posts: 9,694

Re: Colors in Sgplot stacked bar chart

And include the version of SAS used as options have been added with later releases.

Esteemed Advisor
Esteemed Advisor
Posts: 6,685

Re: Colors in Sgplot stacked bar chart

A good idea for a sticky this.  If your having any graph issues or need some examples on things, search this extremely helpful blog:

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

Pretty much everything you can imagine is covered, normally with sgplot and template examples.  In your case you might get away with %modstyle() macro call:

SAS/STAT(R) 9.22 User's Guide

SAS Super FREQ
Posts: 863

Re: Colors in Sgplot stacked bar chart

If you have SAS 9.3 or greater, you can create an attributes map to assign attributes (including color) to specific group values. If you do not care about specifically assigning colors, and you have SAS 9.4 or greater, you can use the DATACOLORS option on the new STYLEATTRS statement to control those colors without modifying the ODS style. Modifying the ODS style is always an option in any release.

Hope this helps!

Dan

Post a Question
Discussion Stats
  • 4 replies
  • 578 views
  • 0 likes
  • 5 in conversation