02-23-2017 09:05 AM
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?
02-23-2017 11:17 AM
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; 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?".