I'm trying to add a star (*) on top of the bars that are significantly different (between the 2 endpoints) in a bar chart. Please see the code below. I've tried using DATALABEL, but SAS won't allow the labels for different bars to be the same. And I can't figure out how to use an annotated dataset here correctly. I'm using SAS version 9.3.
In my dataset I have 2 different endpoints (type) and 5 treatment groups (group).
PROC SGPLOT DATA=work10;
VBARPARM CATEGORY=group RESPONSE=gm/ GROUP=type LIMITUPPER=Upper2;
YAXIS LABEL="Geometric mean (AU/mL)";
KEYLEGEND / TITLE="Groups";
Is there any way to do this?
The key here is the LIMITUPPER request. Data labels over the bars are not allowed when LIMITUPPER/LIMITLOWER are used. Without that option, the DATALABEL option works as expected, as demonstrated by the following program:
proc summary data=sashelp.class nway; class age sex; var weight; output out=temp mean= uclm=uclm; run; data dlabel; set temp; if (sex eq 'M') then dlabel="*"; else dlabel=" "; run; proc sgplot data=dlabel; vbarparm category=age response=weight / group=sex datalabel=dlabel groupdisplay=cluster; run;
Fortunately, you can use annotation to get around this issue. But, my question to you is, "Do you want the star on top of the bar, or at the end of the limit bar?".
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.