Hello all,
The following program creates the data labels separate from the graph and places them on the right hand-side. is there any option to put the data labels right on top of each bar (and the ends of each bar for the confidence limits)?
Thanks a lot in advance!
Recep
proc sgplot data=rr_blunt_penetrating_01;
hbarparm category=Site response=Log_RR/ limitlower=Log_LCL
limitupper=Log_UCL
datalabel;
run;
add another option to hbarparam, eg
DATALABELPOS=DATA
If it does not work please provide sample data
Sorry for the late response, just got back from a quick break!
I already tried the DATALABELPOS=data option but it did not work for me. It simply places the labels on the right hand-side of the figure:
Below is the sample data and the SGPLOT code.
Thanks a lot again!
Recep
data relative_risks;
input hospital $ RR LCL UCL;
cards;
Hosp1 1.00424 0.82114 1.22818
Hosp2 0.8101 0.6657 0.98582
Hosp3 0.90292 0.68763 1.1856
Hosp4 1.06134 0.82583 1.36402
Hosp5 0.79188 0.56884 1.10237
Hosp6 0.85667 0.74326 0.98739
Pooled 0.89249 0.81989 0.97151
run;
ods graphics on;
ods html style=statistical;
proc sgplot data=relative_risks;
hbarparm category=hospital response=RR/ limitlower=LCL
limitupper=UCL
datalabel
datalabelpos=DATA;
run;
ods graphics off;
ods html close;
Given your use case, you could drop the DATALABEL option and overlay a TEXT plot on top of the HBARPARM. Use the same variables you used for the HBARPARM to place the text values. Use the POSITION option on the TEXt statement to adjust the text position around the data points.
Hope this helps!
Dan
Thanks a lot for this Dan! I'll definitely try it. I was hoping to find a straight option but it seems like there is no one within the SGPLOT.
Recep
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.