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

HI there, 

I am having some difficulty changing the bar colors on my graphs. 

Here is my code. 

TITLE1 "Hypertension-Related Death Rates by State";
FOOTNOTE 'Created by Me';
PROC SGPLOT DATA = Hypertension.StatePercents;
VBAR StateCd / Response=colpercent
GROUPDISPLAY=cluster
DATALABEL = ColPercent
;

REFLINE 1.8
/ AXIS = Y
LABELLOC = inside
LINEATTRS=(COLOR = INDIGO PATTERN = SHORTDASH)
LABEL = 'National Average = 1.8';

XAXIS LABEL = 'State Code'
LABELATTRS= (WEIGHT = BOLD)
;

STYLEATTRS DATACOLORS= (LIGHTSALMON)
DATACONTRASTCOLORS= (BLACK)
;

YAXIS LABEL = 'PERCENT'
OFFSETMIN= 0
LABELATTRS= (WEIGHT = BOLD)
VALUES = (0,1,2,3,4)
GRID;
RUN;
TITLE;
FOOTNOTE;

my output is still using blue bars instead of salmon, any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

To change all bars to use the same color use the FILLATTRS option on the VBAR statement.

VBAR StateCd / Response=colpercent
GROUPDISPLAY=cluster
DATALABEL = ColPercent
Fillattrs=(color=lightsalmon)
;

  Your Styleattrs requires at least one GROUP= variable in a plot statement

Requirement For this option to have an effect, at least one plot statement in the procedure must specify the GROUP= option.

View solution in original post

2 REPLIES 2
ballardw
Super User

To change all bars to use the same color use the FILLATTRS option on the VBAR statement.

VBAR StateCd / Response=colpercent
GROUPDISPLAY=cluster
DATALABEL = ColPercent
Fillattrs=(color=lightsalmon)
;

  Your Styleattrs requires at least one GROUP= variable in a plot statement

Requirement For this option to have an effect, at least one plot statement in the procedure must specify the GROUP= option.
Reeza
Super User
Specify the color?

VBAR StateCd / Response=colpercent
GROUPDISPLAY=cluster
DATALABEL = ColPercent
FILL
FILLATTRS=(color = "cxffa07a")
;

I just googled the code for light salmon so you may need to change that. The CX should be in front if you're using Hex codes.
Otherwise, specify your colour using any of these specifications:
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=graphref&docsetTarget=p0e...

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1120 views
  • 0 likes
  • 3 in conversation