Desktop productivity for business analysts and programmers

Data label in a Stacked Bar Graph

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 108
Accepted Solution

Data label in a Stacked Bar Graph

 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


Accepted Solutions
Solution
‎10-31-2017 07:12 PM
SAS Employee
Posts: 199

Re: Data label in a Stacked Bar Graph

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


All Replies
SAS Employee
Posts: 199

Re: Data label in a Stacked Bar Graph

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

Frequent Contributor
Posts: 108

Re: Data label in a Stacked Bar Graph

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

 

Solution
‎10-31-2017 07:12 PM
SAS Employee
Posts: 199

Re: Data label in a Stacked Bar Graph

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

Frequent Contributor
Posts: 108

Re: Data label in a Stacked Bar Graph

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

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 616 views
  • 0 likes
  • 2 in conversation