BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DipuRahman
Calcite | Level 5

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!

pivot_chart.JPG

 

Sample data:

divisionopen_date
Electrophysiology1-Mar-20
Endoscopy1-Mar-20
Endoscopy1-Mar-20
Endoscopy1-Mar-20
IC1-Mar-20
IC1-Mar-20
Urology1-Aug-20
Urology1-Aug-20
Urology1-Aug-20
Urology1-Aug-20
Urology1-Aug-20
Urology1-Aug-20
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

 

View solution in original post

3 REPLIES 3
ballardw
Super User

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
Calcite | Level 5
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?
ballardw
Super User

@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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 886 views
  • 1 like
  • 2 in conversation