SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Abishekaa
Obsidian | Level 7
proc sgplot data=Freq2Out;
  vbar ergRod/response=percent group=cyanToRed5dBGreater fillpattern nofill Groupdisplay=cluster datalabel=Count datalabelattrs=(size=12) name="ERG";
  format ergRod ergRod.;
  yaxis label = 'Percent of Participants (%)' labelattrs=(size=13) valueattrs=(size=13);
  xaxis label = 'Presence of Rod ERG' discreteorder=data labelattrs=(size=13) valueattrs=(size=13);
  keylegend "ERG"/ valueattrs=(Size=13)sortorder=ascending title="DAVF" titleattrs=(size=13) autoitemsize; 
run;

The "datalabel=Count" statement puts the counts of each bar at the top of the plot (Eg: 10, 20). I could like to add a label "n=", so that it shows as "n=10", "n=20" etc at the top of each bar. Is there any options in SAS to do this?

 

Thanks so much!

3 REPLIES 3
tarheel13
Rhodochrosite | Level 12

@Rick_SAS is there a way? 

Rick_SAS
SAS Super FREQ

I would use the XAXISTABLE statement to put the summary statistics under the bars. See

https://blogs.sas.com/content/graphicallyspeaking/2013/12/16/grouped-bar-chart-with-statisticstable/

 

Abishekaa
Obsidian | Level 7
Thank you, Rick 🙂

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register 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
  • 3 replies
  • 1798 views
  • 0 likes
  • 3 in conversation