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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1162 views
  • 0 likes
  • 2 in conversation