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


Hi,

 

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;
XAXIS DISCRETEORDER=DATA;
YAXIS LABEL="Geometric mean (AU/mL)";
KEYLEGEND / TITLE="Groups";
RUN;

 

Is there any way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Since you are using VBARPARM, you should be able to overlay a scatter plot with y=upper2 to plot markers where you want them.

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

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?".

DeniseQPS
Calcite | Level 5

Thank you Dan, that explains why the datalabel option doesn't work. I would prefer the star to be at the end of the limit bar. 

Jay54
Meteorite | Level 14

Since you are using VBARPARM, you should be able to overlay a scatter plot with y=upper2 to plot markers where you want them.

DeniseQPS
Calcite | Level 5

Ah, thank you Sanjay. That seems to be doing the trick!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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