Hey everyone!
I have included a chart I made from Excel. Attached the group chart below. It displays the monthly frequency distributions by division. In this example it's 3 months grouped together. I'm attempting to recreate this chart with from base SAS (9.4).
I have also included sample data below. Does anyone know what's the best method (like PROC GCHART, etc.) is to create this graph? I also need to display the legend as shown.
Thank you!
Sample data:
division | open_date |
Electrophysiology | 1-Mar-20 |
Endoscopy | 1-Mar-20 |
Endoscopy | 1-Mar-20 |
Endoscopy | 1-Mar-20 |
IC | 1-Mar-20 |
IC | 1-Mar-20 |
Urology | 1-Aug-20 |
Urology | 1-Aug-20 |
Urology | 1-Aug-20 |
Urology | 1-Aug-20 |
Urology | 1-Aug-20 |
Urology | 1-Aug-20 |
What makes the height of the bar? You don't show any other values.
Basic approach would be something like:
proc sgplot data=have; vbar division / group=open_date groupdisplay=cluster <vertical option goes here>
datalabel ; run;
Where I have vertical option goes here could be a variable used to create the height. That would be Response=variablename.
Or a statistic calculated from the data: stat= <one of> freq mean median percent sum. Mean, median and sum require a response variable to calculate from, freq would be the number of times the category variable, division in this case, appears or percent the percent of the category variable. The datalabel shows the value of the statistic, or a different variable, at the end of the bar.
There a lots of options involved for specific appearance and behavior.
What makes the height of the bar? You don't show any other values.
Basic approach would be something like:
proc sgplot data=have; vbar division / group=open_date groupdisplay=cluster <vertical option goes here>
datalabel ; run;
Where I have vertical option goes here could be a variable used to create the height. That would be Response=variablename.
Or a statistic calculated from the data: stat= <one of> freq mean median percent sum. Mean, median and sum require a response variable to calculate from, freq would be the number of times the category variable, division in this case, appears or percent the percent of the category variable. The datalabel shows the value of the statistic, or a different variable, at the end of the bar.
There a lots of options involved for specific appearance and behavior.
@DipuRahman wrote:
Hi @ballardw ! Thank you for the quick response. The height of the bar is the count of "opens" for the month. So for example for Endoscopy, the count would be 3 for March-2020.
Sounds like I could do something like stat=freq?
I think you have the correct approach.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.