I am using sas 9.4 on a 64-bit machine. I have a dataset like this
data totals;
length dept $ 7 site $ 8 tx_sale $20 ;
INFILE DATALINES DLM='#';
input dept site quarter sales tx_sale ;
datalines ;
Parts#Sydney#1#0# N/A#
Parts#Atlanta#1#50##
Parts#Paris#1#60# #
Tools#Shanghai#4#0#N/A#
Tools#Athen#4#35##
Tools#Pittsburg#4#48##
;
run;
And I want to generate a bar chart with datalabel I specified in column tx_sale and the color of the bar indicating dept
I used code below:
proc sgplot data=totals;
hbar site / response=sales missing datalabel=tx_sale;
run;
The chart generated by the code didn't have the color
If I used code below :
proc sgplot dat=totals;
hbar site / group=dept response=sales missing datalabel=tx_sale;
run;
The chart generated by the code didn't have the datalabels.
How can I have both color bar and data label on the same chart? Thank you
On the VBAR statement, add GROUPDISPLAY=CLUSTER. The bar will not be stacked, but your labels should appear. Will that work for you?
Yes, it works. Thank you very much!
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.
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.