BookmarkSubscribeRSS Feed
pacman94
Calcite | Level 5

Hello. I am trying to created a stacked bar chart by record ID and year. I would like the x-axis to be 'rate' and inside each stacked bar chart, I would like to have data labels as 'enrolled'

 

Here is the dataset:

recordIDyearenrolledrate
12018831.81818
120191354.54545
120201668.18182
22019936.36364
220201250
320182554.7619
320197590
3202095100
4201924.545455

 

 

my attempt thus far:

 

data test;
infile datalines missover;
input recordID year enrolled rate;
datalines;
1 2018 8 31.81818
1 2019 13 54.54545
1 2020 16 68.18182
2 2019 9 36.36364
2 2020 12 50
3 2018 25 54.7619
3 2019 75 90
3 2020 95 100
4 2019 2 4.545455
;run;


proc sgplot data=test pctlevel=graph;
hbar recordID / response=rate stat=percent
group=year groupdisplay=stack datalabel;
keylegend /title="Location" position=bottom;
quit;

 

Not able to get what I needgraph.JPG

 

This is what I would like (attached)

 

 

 

1 REPLY 1
ballardw
Super User

I think you are looking for the SEGLABEL option:

 

proc sgplot data=test pctlevel=graph;
   hbar recordID / response=rate stat=percent
   group=year groupdisplay=stack seglabel;
   keylegend /title="Location" position=bottom;
run;

to label segments of the bar.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 313 views
  • 0 likes
  • 2 in conversation