我用PROC GCHART
创建了一个图表。假设数据如下所示:
Month Volume
Jan 2
Feb 4
May 19
Sep 7
当我用GCHART使用月和量创建图形时,我得到四个条形图。不过,我希望看到全年的情况(剩下的月份用空栏表示)。我试着使用:
axis order=('Jan','Feb',...,'Nov','Dec');
但是,我仍然只得到4列而不是12列。我能做什么?
谢谢。
您需要创建一个包含无数据月份的数据集。然后将该数据集与AXIS语句一起使用,以强制在GCHART中显示所有月份。请参阅下面的示例代码。希望对你有帮助。
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;