Hi all,
When I'm adding a datalabel to an hbar plot the label variable name is appearing on the plot but only when I right align the label text. Does anyone know I can get rid of the variable name but keep the datalabel right aligned.
Code below:
proc sgplot data=median_time_plot noborder;
hbar id / response=med group=nrp groupdisplay=cluster datalabel=lab datalabelpos=right datalabelattrs=(weight=BOLD size=10);
format med HHMM.;
title " ";
xaxis label=" ";
yaxis label=" ";
run;
See the graph below, the "lab" at the top of the chart is what I want to get rid of and only appears when datalabelpos=right.
Thanks for any help and advice!
You get that labeling because of the GROUP variable. Here's another way you can show that information, but have have the control to remove that label in a grouping situation:
proc sgplot data=median_time_plot noborder;
hbar id / response=med group=nrp groupdisplay=cluster;
yaxistable lab / classdisplay=cluster nolabel valueattrs=(weight=BOLD size=10);
format med HHMM.;
title " ";
xaxis label=" ";
yaxis label=" ";
run;
Hope this helps!
Dan
Can you post your code please?
I've added the code to the original post, thanks for the reply
You get that labeling because of the GROUP variable. Here's another way you can show that information, but have have the control to remove that label in a grouping situation:
proc sgplot data=median_time_plot noborder;
hbar id / response=med group=nrp groupdisplay=cluster;
yaxistable lab / classdisplay=cluster nolabel valueattrs=(weight=BOLD size=10);
format med HHMM.;
title " ";
xaxis label=" ";
yaxis label=" ";
run;
Hope this helps!
Dan
Thanks Dan, works perfectly.
If you've got time to elaborate, can you explain a bit how the GROUP variable caused the issue?
The DATALABELPOS option is basically a convenience option I added to do what I showed you with an AXISTABLE. With that convenience, I have to make some decisions internally. One of those involves labeling. If there is no GROUP, there is no point in showing a label, so no label appears. But, for a GROUP situation, I normally need to show a label so that you can identify each set of values per group value. For CLUSTER situations, however, that label is not as useful. Just know that XAXISTABLE/YAXISTABLE statements will give you the most control when creating "tabular" labeling.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.