用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.zhenglaiyi.com/957.html

(4)
郑来轶的头像郑来轶
上一篇 2019-02-02 15:16
下一篇 2019-06-01 15:52

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注