Reputation: 3099
The following code gives a side by side chart
data a;
input Salesman $ 1-6 Year Sales;
datalines;
Bob 2009 6
Anna 2009 8
Carl 2009 9
Bob 2010 7
Anna 2010 9
Carl 2010 10
;
run;
axis1 label=none order=(0 to 30 by 10) minor=none offset=(0,0);
axis2 label=none offset=(15,15);
legend1 position=(right middle) across=1 label=none
shape=bar(.13in,.13in) order=('Carl' 'Bob' 'Anna');
pattern1 v=s c=yellow;
pattern2 v=s c=orange;
pattern3 v=s c=red;
proc gchart data=a;
vbar year / discrete type=sum sumvar=sales
raxis=axis1 maxis=axis2 width=15 space=8
noframe autoref clipref cref=graycc
subgroup=Salesman legend=legend1;
run;
However it plots the bars one on the top of another. The bottomline I have a stacked
, but I need clustered
graph .
Upvotes: 1
Views: 3411
Reputation: 393
PROC GCHART gives me a headache!!! I second Robslink.com as a good resource for SAS/GRAPH examples. I think your code is almost there, try this (change VBAR to use SALESMAN instead of YEAR and also add the GROUP option.
proc gchart data=a;
vbar /*year*/ Salesman / discrete type=sum sumvar=sales
raxis=axis1 maxis=axis2 width=15 space=8
noframe autoref clipref cref=graycc
subgroup=Salesman group=year legend=legend1;
run;
Upvotes: 3
Reputation: 63424
It's possible in gchart, but I suggest sgplot instead; it's much easier. One example from Sanjay Patel's blog, Graphically Speaking:
proc sgplot data=sashelp.prdsale;
title 'Actual Sales by Product and Quarter';
vbar product / response=actual group=quarter groupdisplay=cluster
dataskin=gloss;
xaxis display=(nolabel);
yaxis grid;
run;
Note groupdisplay=cluster
, which is what's making it clustered (not groupdisplay=stacked
).
For your data:
proc sgplot data=a;
vbar year/group=salesman response=sales groupdisplay=cluster;
run;
I believe the gchart
answer is that you need to use the group
statement to create clusters (as opposed to subgroup
which is creating the stacked element). You also need a functional gaxis
for that to work. See this Robslink.com example for more detail. (Robslink.com should probably be the first place to go for gchart
and gplot
help; Rob Allison, who works at SAS Institute, maintains it and has an incredible set of charts there, plus sample code.)
Upvotes: 3