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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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