Data visualization with SAS programming

Colors in Sgplot stacked bar chart

Posts: 1

Colors in Sgplot stacked bar chart


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;


proc freq data=t.indic_f noprint;

table RETARD_PAT/out=test3;

by A;


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.;


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

Super User
Posts: 9,865

Re: Colors in Sgplot stacked bar chart

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

Super User
Posts: 11,114

Re: Colors in Sgplot stacked bar chart

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

Super User
Super User
Posts: 7,695

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:

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

Posts: 925

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!


Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation