BookmarkSubscribeRSS Feed
mcknigh3
Fluorite | Level 6

I am having difficulty adding significance letters to the tops of the bars in Proc sgplot. I have error bars shown too and everything I've read says I can't have both error bars and letter. Is this true? The letters appear on the graph but not where I'd like them to be. Here's my code and data attached:

 

Proc sgplot data=LSMSPwk1interact noborder;
vbarparm category=Treatment response=Estimate / limitlower=limitlower limitupper=limitupper limitattrs=(color=black Thickness=1.75)
group=Foragetype groupdisplay=cluster fill barwidth=0.85 datalabel=Sigletter datalabelpos=top
datalabelattrs=(color=black Family="Times New Roman" Size=12);
styleattrs datacolors=(dagrybr bgr grybr);
xaxis Label= 'Treatment' labelattrs=(color=black Family="Times New Roman" Size=12) valueattrs=(color=black Family="Times New Roman" Size=12);
yaxis min=-2 max=100 grid Label= 'Proportion (%)' labelattrs=(color=black Family="Times New Roman" Size=12)
valueattrs=(color=black Family="Times New Roman" Size=12);
keylegend / title="" position=top noborder valueattrs=(color=black Family="Times New Roman" Size=12)
titleattrs=(color=black Family="Times New Roman" Size=12);
Run;

1 REPLY 1
Reeza
Super User

Try using a TEXT statement instead of datalabel and provide the x/y location.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n0lprj1bdrlrkgn1vmqnd7r6fnry.htm

 


@mcknigh3 wrote:

I am having difficulty adding significance letters to the tops of the bars in Proc sgplot. I have error bars shown too and everything I've read says I can't have both error bars and letter. Is this true? The letters appear on the graph but not where I'd like them to be. Here's my code and data attached:

 

Proc sgplot data=LSMSPwk1interact noborder;
vbarparm category=Treatment response=Estimate / limitlower=limitlower limitupper=limitupper limitattrs=(color=black Thickness=1.75)
group=Foragetype groupdisplay=cluster fill barwidth=0.85 datalabel=Sigletter datalabelpos=top
datalabelattrs=(color=black Family="Times New Roman" Size=12);
styleattrs datacolors=(dagrybr bgr grybr);
xaxis Label= 'Treatment' labelattrs=(color=black Family="Times New Roman" Size=12) valueattrs=(color=black Family="Times New Roman" Size=12);
yaxis min=-2 max=100 grid Label= 'Proportion (%)' labelattrs=(color=black Family="Times New Roman" Size=12)
valueattrs=(color=black Family="Times New Roman" Size=12);
keylegend / title="" position=top noborder valueattrs=(color=black Family="Times New Roman" Size=12)
titleattrs=(color=black Family="Times New Roman" Size=12);
Run;


 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1667 views
  • 0 likes
  • 2 in conversation