BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8
I'm using gchart to create a bar chart.
All of the bars are orange.
For bu="dog" I would like the bar to be black.
How do I accomplish this?
Thank you.
proc gchart data=goals anno=cbackanno;
hbar bu /
ascending
discrete
woutline=1
sumvar=rate
freqlabel=" " sumlabel='Total'
cframe=white
maxis=axis1
raxis=axis2
space=0.6
width=2;
run;
quit;
3 REPLIES 3
DanH_sas
SAS Super FREQ
You can use a small datastep and the SUBGROUP option to do it. Make sure the color value you want black ("dog" in this case) is 0. Here is an example:

[pre]
data test;
set sashelp.class;
if age=14 then color=0;
else color=1;
run;

pattern1 c=black;
pattern2 c=orange repeat=10;

proc gchart data=test;
vbar age / discrete subgroup=color;
run;
quit;
[/pre]
DanH_sas
SAS Super FREQ
A couple of adjustments to the program I posted:
1) You can remove the REPEAT=10. It is not needed.
2) You will probably want to add the NOLEGEND option to the VBAR statement.

Thanks!
Dan
gzr2mz39
Quartz | Level 8
Looks good.
Thank you.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 1472 views
  • 0 likes
  • 2 in conversation