BookmarkSubscribeRSS Feed
sustagens
Pyrite | Level 9

I have limited graphing experience, but keen for some help on creating a wide bar chart with two groups, by YrMth and then by Category. Each category has 3 types, which will represent a bar. I had a look at this question which is similar although not quite what I need.

 

Here is some sample data:

data have;
  infile cards;
  input 
YrMth
Category : $32.  
Type : $32.
Amount
;
cards;
202004 Single End 68.61
202004 Single Avg 83.02
202004 Single Profit 56.86
202004 Duplex End 61.16
202004 Duplex Avg 53.72
202004 Duplex Profit 86.79
202004 Condo End 64.08
202004 Condo Avg 32.99
202004 Condo Profit 64.08
202005 Single End 68.61
202005 Single Avg 83.02
202005 Single Profit 56.86
202005 Duplex End 61.16
202005 Duplex Avg 53.72
202005 Duplex Profit 86.79
202005 Condo End 64.08
202005 Condo Avg 32.99
202005 Condo Profit 64.08
202006 Single End 68.61
202006 Single Avg 83.02
202006 Single Profit 56.86
202006 Duplex End 61.16
202006 Duplex Avg 53.72
202006 Duplex Profit 86.79
202006 Condo End 64.08
202006 Condo Avg 32.99
202006 Condo Profit 64.08
202007 Single End 68.61
202007 Single Avg 83.02
202007 Single Profit 56.86
202007 Duplex End 61.16
202007 Duplex Avg 53.72
202007 Duplex Profit 86.79
202007 Condo End 64.08
202007 Condo Avg 32.99
202007 Condo Profit 64.08
;
run;

What I have:

proc sgplot data=have noborder;
  vbar Category / group=Type groupdisplay=cluster response=amount grouporder=data ;
  yaxis values=(0 to 100 by 10) display=(nolabel);
  xaxis values=("Single" "Duplex" "Condo") display=(nolabel);

  keylegend / location=outside position=right noborder title=" ";
run;

What I want to achieve:

Capture.JPG

 
3 REPLIES 3
Reeza
Super User
Can you use SGPANEL for it?
Otherwise I think this falls into the custom graphs which means going down the GTL route.
Rick_SAS
SAS Super FREQ
proc sgpanel data=have ;
  panelby YrMth; /* OPTIONAL: control layout options */
  vbar Category / group=Type groupdisplay=cluster response=amount grouporder=data ;
  rowaxis values=(0 to 100 by 10) display=(nolabel);
  colaxis values=("Single" "Duplex" "Condo") display=(nolabel);
run;
ghosh
Barite | Level 11

proc sgpanel data=have ;
  panelby YrMth / onepanel layout=columnlattice colheaderpos=bottom noborder novarname; 
  vbar Category / group=Type groupdisplay=cluster response=amount grouporder=data ;
  rowaxis display=(nolabel);
  colaxis display=(nolabel);   
run;

Untitled.png

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3117 views
  • 1 like
  • 4 in conversation