用SAS进行数据分析:绘制累积柱状图并添加折线

用SAS绘制累积柱状图并添加折线。

SAS累计堆积图

PS:直接上代码,对SAS CODE不熟悉的可以绕行。

GOPTIONS RESET=ALL BORDER CBACK=WHITE HTITLE=12PT;

DATA A;

INPUT SUBVAR $ XVAR MMDDYY6. VBAR_Y PLOT_Y;

DATALINES;

SUB1 010196 10 8

SUB1 020196 20 15

SUB1 030196 30 55

SUB1 040196 40 50

SUB1 050196 50 40

SUB2 010196 10 8

SUB2 020196 20 15

SUB2 030196 30 55

SUB2 040196 40 50

SUB2 050196 50 40

;

RUN;

DATA ANNO;

LENGTH FUNCTION COLOR $8 TEXT $10;

RETAIN XSYS YSYS ‘2’ WHEN ‘A’;

SET A END=LAST;

BY SUBVAR;

IF FIRST.SUBVAR THEN FUNCTION=’MOVE’;

ELSE FUNCTION=’DRAW’;

X=XVAR; Y=PLOT_Y;

SIZE=1;

COLOR=’BLACK’; OUTPUT;

FUNCTION=’SYMBOL’;

XSYS=’2′; YSYS=’2′;

X=XVAR; Y=PLOT_Y;

TEXT=’DOT’; SIZE=2; COLOR=’DEPK’;

OUTPUT;

RUN;

AXIS1 LABEL=(‘MONTH’);

AXIS2 LABEL=(‘SALES’);

LEGEND1 LABEL=(‘ACTUAL’) VALUE=(‘1ST QTR’ ‘2ND QTR’);

TITLE1 ‘OVERLAY A LINE ON TOP OF GCHART OUTPUT USING ANNOTATE’;

PROC GCHART DATA=A;

VBAR XVAR / SUMVAR=VBAR_Y ANNO=ANNO WIDTH=8

MIDPOINTS=’01JAN96’D TO ’01MAY96’D BY MONTH

SUBGROUP=SUBVAR MAXIS=AXIS1 RAXIS=AXIS2

LEGEND=LEGEND1;

FORMAT XVAR MONNAME3.;

FORMAT VBAR_Y DOLLAR6.;

RUN;

QUIT;

本文为专栏文章,来自:郑来轶,内容观点不代表本站立场,如若转载请联系专栏作者,本文链接:https://www.afenxi.com/1512.html 。

(0)
郑来轶的头像郑来轶专栏
上一篇 2015-11-03 22:36
下一篇 2015-11-03 22:47

相关文章

关注我们
关注我们
分享本页
返回顶部