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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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