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

 All,

 

I'm trying to add data labels into a stacked bar graph.

 

Part of my data looks like this:

 

CategoryPerEVENT_DT
ATTPerc  67.16%25/09/2017
AHoldPerc12.29%25/09/2017
ACWPerc  20.55%25/09/2017
ATTPerc  68.25%26/09/2017
AHoldPerc12.18%26/09/2017
ACWPerc  19.57%26/09/2017
ATTPerc  68.11%27/09/2017
AHoldPerc12.57%27/09/2017
ACWPerc  19.32%27/09/2017
ATTPerc  67.87%28/09/2017
AHoldPerc11.28%28/09/2017
ACWPerc  20.84%28/09/2017
ATTPerc  69.01%29/09/2017
AHoldPerc12.09%29/09/2017
ACWPerc  18.90%29/09/2017
ATTPerc  67.98%2/10/2017
AHoldPerc11.91%2/10/2017
ACWPerc  20.12%2/10/2017

 

 

 

proc sgplot data=work.AHT_OTH_PercCalc;
	vbar EVENT_DT / response=Per Group=Category datalabel seglabel ;
	YAXIS max=1 Label="Percentage" Values=(.1 to 1 by .05);
run;

 

I have tried datalabel seglabel however only the datalabel is showing in the chart.

 

100% BarChart.GIF

 

How can I get the datalabels to show?

 

SAS Ver.GIF

 

 

All help appreciated.

 

Cheers

 

Dean

1 ACCEPTED SOLUTION

Accepted Solutions
Damo
SAS Employee

Hi Dean,

 

With SAS9.4TS1M2, this is the output I get using your data and program.

Seglabel_output.JPG

 

If you add the "seglabelattrs=(size=8)" instructions, what is the result?

 

Cheers,

Damo

View solution in original post

4 REPLIES 4
Damo
SAS Employee

Hi @DME790

 

Are you trying to display the value of the PER variable?

As per the documentation, SEGLABEL should do the trick but it is new with SAS 9.4M2.

Seglabel.JPG

 

Which version are you using?

If you try to use Sample 55866 (Use the SEGLABEL option to label bar segments in a bar chart, what is the result?)

 

Cheers,
Damo

DME790
Pyrite | Level 9

Hi @Damo,

 

I can run Sample 55866 and it shows the segment results

 

Sample55866.GIF

 

I have got seglabel in the code however it doesn't display the segment values in the bars.

 

I am using 9.4 m2 

proc sgplot data=work.AHT_OTH_PercCalc;
	vbar EVENT_DT / response=Per Group=Category stat=SUM datalabel seglabel ;
	YAXIS max=1 Label="Percentage" Values=(.1 to 1 by .05);
run;

It shows the datalabel at the top of the bars but not the segments.

 

MyGraph.GIF

 

Cheers

 

Dean

 

Damo
SAS Employee

Hi Dean,

 

With SAS9.4TS1M2, this is the output I get using your data and program.

Seglabel_output.JPG

 

If you add the "seglabelattrs=(size=8)" instructions, what is the result?

 

Cheers,

Damo

DME790
Pyrite | Level 9

Hi @Damo,

 

It is now showing the per values. Not sue what happened as I haven't changed any code - feel silly now.

 

Thanks for all the support.

 

Cheers

 

Dean

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5431 views
  • 0 likes
  • 2 in conversation