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:
recordID | year | enrolled | rate |
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 |
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 need
This is what I would like (attached)