I create a chart with PROC GCHART
. Assume the data looks like this:
Month Volume
Jan 2
Feb 4
May 19
Sep 7
When I create the graph with GCHART using Month and Volume, I get four bars. I would like to see the entire year though (with empty columns for the remaining months). I tried using :
axis order=('Jan','Feb',...,'Nov','Dec');
but still, I only get four columns instead of twelve. What can I do?
Thanks.
You need to create a dataset that includes the months without data. Then use that dataset with your AXIS statement to force all months to appear in GCHART. See the example code below. Hope this helps.
data have;
infile cards;
input Month $ Volume;
cards;
Jan 2
Feb 4
May 19
Sep 7
;
run;
*** CREATE A DATASET WITH ALL 12 MONTHS ***;
data allmon;
infile cards;
input Month $ @@;
cards;
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
;
run;
*** USE PROC SQL TO MERGE BOTH DATASETS WITHOUT HAVING TO SORT FIRST ***;
*** USE THIS DATASET WITH GCHART ***;
proc sql;
create table want as
select *
from allmon left join have
on (allmon.month = have.month)
;
run;
proc print data=want;
run;
axis1 order=('Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec');
proc gchart data=want;
vbar month / sumvar=volume maxis=axis1;
run;