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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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