SAS Enterprise Guide

Desktop productivity for business analysts and programmers
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-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!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 6682 views
  • 0 likes
  • 2 in conversation