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

Hello,

 

I am trying to add data labels to my bar chart. Currently I am getting the variable instead of an actual value in percent.

 

Can you help?

 

Code:

title 'Game Attendance Percentages';
proc sgplot data=profoot.pro_football_segments;
	hbar game_attendance /datalabel=game_attendance stat=percent  fillattrs=(color=grey);
	xaxis label='Percentage of Game Attendance' labelattrs=(size=12);
	yaxis label='Game Attendance' labelattrs=(size=12);
run; 

Log:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         title 'Game Attendance Percentages';
 63         proc sgplot data=profoot.pro_football_segments;
 64         hbar game_attendance /datalabel=game_attendance stat=percent  fillattrs=(color=grey);
 65         xaxis label='Percentage of Game Attendance' labelattrs=(size=12);
 66         yaxis label='Game Attendance' labelattrs=(size=12);
 67         run;
 
 NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           0.79 seconds
       cpu time            0.29 seconds
       
 NOTE: There were 473 observations read from the data set PROFOOT.PRO_FOOTBALL_SEGMENTS.
 
 68         
 69         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 82         

Results:

Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Simply erase the 

 

=game_attendance

from your hbar options so that the code is

 

title 'Game Attendance Percentages';
proc sgplot data=profoot.pro_football_segments;
	hbar game_attendance / datalabel stat=percent  fillattrs=(color=grey);
	xaxis label='Percentage of Game Attendance' labelattrs=(size=12);
	yaxis label='Game Attendance' labelattrs=(size=12);
run; 

 

 

 

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Simply erase the 

 

=game_attendance

from your hbar options so that the code is

 

title 'Game Attendance Percentages';
proc sgplot data=profoot.pro_football_segments;
	hbar game_attendance / datalabel stat=percent  fillattrs=(color=grey);
	xaxis label='Percentage of Game Attendance' labelattrs=(size=12);
	yaxis label='Game Attendance' labelattrs=(size=12);
run; 

 

 

 

bldudley
Obsidian | Level 7

Thank you! I had tried that previously but it wasn't working.

 

I appreciate your help!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 3 replies
  • 6726 views
  • 2 likes
  • 2 in conversation