BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RoddyJ
Obsidian | Level 7

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. 

 

 

barchart_lab_redacted.png 

 

Thanks for any help and advice!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Can you post your code please?

RoddyJ
Obsidian | Level 7

I've added the code to the original post, thanks for the reply

DanH_sas
SAS Super FREQ

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

RoddyJ
Obsidian | Level 7

Thanks Dan, works perfectly. 

 

If you've got time to elaborate, can you explain a bit how the GROUP variable caused the issue?

DanH_sas
SAS Super FREQ

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.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 855 views
  • 4 likes
  • 3 in conversation