- 在线时间
- 5024 小时
- 最后登录
- 2022-11-28
- 注册时间
- 2009-4-8
- 听众数
- 738
- 收听数
- 1
- 能力
- 23 分
- 体力
- 77272 点
- 威望
- 96 点
- 阅读权限
- 255
- 积分
- 27108
- 相册
- 1
- 日志
- 14
- 记录
- 36
- 帖子
- 4293
- 主题
- 1341
- 精华
- 15
- 分享
- 16
- 好友
- 1975

数学中国总编辑
TA的每日心情 | 衰 2016-11-18 10:46 |
|---|
签到天数: 206 天 [LV.7]常住居民III 超级版主
 群组: 2011年第一期数学建模 群组: 第一期sas基础实训课堂 群组: 第二届数模基础实训 群组: 2012第二期MCM/ICM优秀 群组: MCM优秀论文解析专题 |
data ex;7 @- i t/ R/ O+ b& e8 U( L g
input x y g color $;9 }) a0 F* J& ^. Z6 j, a! C% h
cards;6 Y: c' w$ r0 M2 z2 c
1 2 1 Yahoo!
. U+ h" n( ?1 V% S* Q( y1 4 2 Google
( J9 g7 ~; E% u" m$ S2 5 1 Yahoo!. [% x8 @2 P5 g4 |, L3 n
2 8 2 Google; d9 X. i0 v. ^. N
4 12 1 Yahoo!% d- E1 k! Q e9 Q$ O
4 10 2 Google
6 r* ^% T) [3 M6 |9 G5 9 1 Yahoo!
5 l b% B+ X5 v2 n6 K5 ~& a0 k5 7 2 Google
3 P" I" C. U% D) s9 M* T* ^7 j;
* }" r" b. y. `2 E3 Y2 |data title_anno;
" x1 ?9 s {7 lwhen=’b'; xsys=’3′; ysys=’3′; style=’solid’;
$ `+ z! K2 O; C/ j; [* v1 efunction=’move’; x=0; y=87; output;
$ H) n" d1 o( ofunction=’bar’; x=100; y=100; color=’black’; output;
% Q! C D' s% l' ?run;
8 x( j' ]( f, o& h- Idata range_anno;7 v/ [/ F5 B, p, l
when=’b'; xsys=’1′; ysys=’1′; style=’solid’;0 r9 P7 G' W* h. Z( M
function=’move’; x=0; y=0; output;
$ U8 j0 U& q1 f7 [$ Z$ gfunction=’bar’; x=100; y=20; color=”cxFFFBDD”;output; V2 H7 n s$ q. ~5 V, V( N
function=’move’; x=0; y=20; output;
$ Y1 T. z% a' ofunction=’bar’; color=”cxEEE3B4″; x=100; y=40; output;
n) G9 J. n/ }1 ^; }function=’move’;x=0; y=40; output;
$ ^" c% C& m5 v# y/ G2 T7 sfunction=’bar’; color=”cxFFFBDD”; x=100; y=60; output;- K# I1 U$ g& Y) R) F5 S' p6 Z
function=’move’;x=0; y=60; output;
) Q' w. b! G" V6 V, d- ?7 V. e2 xfunction=’bar’; color=”cxEEE3B4″; x=100; y=80; output;! q3 R! S* N; d0 Z. ?; D6 q
function=’move’;x=0; y=80; output;; g4 ?$ g# Q) ~0 h2 a' I
function=’bar’; color=”cxFFFBDD”; x=100; y=100; output;
' F, ]0 y: B8 _9 z9 [( _2 K( Orun;
4 w0 M9 g! l5 V! J1 y3 xdata range_anno1;0 X3 N) p, _; y, y2 s& [0 @- r% G
when=’b'; xsys=’1′; ysys=’1′;
9 \4 ?) ~" `3 w8 k+ _function=’move’; x=0; y=20; output;
* S: T# q2 _* {. P6 e8 d( {8 xfunction=’bar’; x=100; y=20; color=”cxD6CECD”;output;9 e( Z! \& ] h( e
function=’move’; x=0; y=40; output;* E9 r( Z' U5 |& V. l7 a
function=’bar’; color=”cxD6CECD”; x=100; y=40; output;
0 S" D% J# }0 Z9 _function=’move’;x=0; y=60; output;
8 l8 v' A4 r5 P' {2 pfunction=’bar’; color=”cxD6CECD”; x=100; y=60; output;
6 x* {1 j3 J. _& F z5 c9 b" B3 m+ ffunction=’move’;x=0; y=80; output;
5 c* e) P* G+ u5 z4 k4 sfunction=’bar’; color=”cxD6CECD”; x=100; y=80; output;0 k: C3 K/ ^3 a9 ^
run; ?5 G: h# ~5 A- N
data range_anno;
5 j1 p6 A2 f8 W( A0 h. M1 Hset range_anno range_anno1;6 c$ J# c* ~6 U" \/ W1 ?3 _
run;; E$ T5 N1 W! o# \/ k; u% H
FILENAME file “c:\bussiness.png”;
" I0 y% ` q* sGOPTIONS reset=all noborder Cback=”cxEEE3B4″ device=png gsfname=file
1 I0 l; r* x8 c! w* |2 T! qvsize=7cm hsize=7cm
( @% D& e5 ]* ? ]4 d# A/ d; symax=8cm xmax=9cm- k, b6 a" a7 I8 N
htext=1.5 ;
( k9 G! i4 h+ e! d- w7 q {axis1 major=none width=2 label=none REFLABEL=none value=(h=1 color=black “Q1″ “Q2″ “Q3″ “Q4″ ) offset=(4,4);
0 x2 y; R; I9 K4 Y" g; Qaxis2 color=black width=2 label=none order=(0 to 13 by 4) minor=none major=(h=1) value=(h=1.0) offset=(0,2);
$ @/ d+ x+ h0 ?axis3 major=none label=none value=none;
/ f) N; I$ P- Tpattern1 v=s color=’cxFF8E00′;: x0 l1 X7 t) ^2 S
pattern2 v=s color=’cx004C7A’;
2 I' }7 }4 |4 W% ntitle j=l BCOLOR=black COLOR=white h=3.5 font=CENTB ” Bussniess weekly style”;$ \2 o. ^( C/ X: c: C
title2 j=l ” Internation compsdfdsfsfd”;
+ K" n) Q6 s' `- l; Q" a1 ^4 q% Ttitle3 j=l ” asdfd asdfdf dfsdfsd”;
6 o# `# E0 ?) |. d7 |0 ilegend1 label=none value=(HEIGHT=1.2 ‘Yahoo!’ ‘Google’ ) POSITION=(inside middle ) OFFSET=(-11,2.5)0 } g: R8 ]6 l0 R
shape=bar(.1in,.1in);' z" z) _8 ^8 k, Z3 M
proc gchart data=ex anno=title_anno;( J1 I" f5 y t+ b0 `
vbar g / discrete type=sum
; s* j: _ v3 _6 h3 x* E" zsumvar=y
k9 m3 I4 L7 y# j5 H- Omaxis=axis1 raxis=axis2 GAXIS=axis3* f+ ]( g+ R) t6 }: u) m
coutline=gray33 caxis=”cxD6D3B8″" P4 Y7 G/ O4 b+ e% N0 K
width=4
9 E# W W- A) T% a$ w! B) |space=0- e2 ~4 E, X) u6 O8 w) n
gspace=07 g( w1 r* k& N% w% l8 R) M0 ^- y( m
subgroup= color. H3 m9 H H$ P* X# E2 E* H
group=x
1 N0 Y3 v& W' v2 R( Blegend=legend1
6 G1 u$ T1 P' W- W# uanno=range_anno ;* A% E" O6 U! q! G
footnote justify=l h=1 font=swiss “ Data from **group”;" z4 g: E1 k n4 P. y" J7 c
footnote2 justify=l h=1 font=swiss “ http://sxlion.blog.sohu.com”;
6 \7 O) h6 e7 @! {, |run;( F, L! @! U- e" S+ D1 b
quit;& g& j% {; L# B- O: r/ l
下面是excelpro博客介绍的经典商业周刊风格的图表,对比一下相差无几。
* \* u3 O& s2 r6 ? ]" N+ F这代码是相当的复杂,调试也比较费功夫。# e0 n1 F [ c5 j7 _- v% E
0 }& ?1 [* d3 k% Q; M
本来准备在sgplot的band语句画区域作为背景来实现的,但是由于存在bar图与band不兼容的情况,于是只好转向anno了。见SAS公司详细说明。% I: q2 b( C( y2 K
There are four basic types of plots that you can create with the SGPLOT procedure:
4 s3 O6 W6 t) U5 W8 BBasic plots
0 h6 }" `0 X6 C; _; i& yscatter, series, step, band, needle, and vector plots
/ ?1 b ~$ X7 H1 q. `% q) WFit and confidence plots
4 A6 }: H3 \! M: W2 ]$ Wloess, regression, and penalized B-spline curves, and ellipses' H4 H; G" @& Z! G8 X0 o2 e
Distribution plots
! `* U7 }& f, y2 [+ X& }3 dbox plots, histograms, and normal and kernel density estimates
) n% n" p. o; v3 Z& hCategorization plots9 U% Z. e5 b/ ^8 i Y
dot plots, bar charts, and line plots
/ F) m u6 a+ I$ ?5 M3 l1 hNot all of the plot types can be used together in the same PROC SGPLOT step. The following table shows which of the plot types can be used together
' D1 M4 m$ y/ J3 `. i" l* V2 R% ?$ Z! }( C/ C( n3 l' c7 H
) U3 o6 J9 U; J: h
data ex;$ M4 ]' g2 g+ U- k& g1 i
input x y ;
5 B! H3 b( `5 n* F, I1 p. I+ Scards;
; O! _/ l; n; T0 u: U" s1 2" I% {6 f8 G) y8 z6 _
2 7
6 D9 ~8 ?0 \# h# m4 12. N6 X% m) C- F7 ^% D( ]& H
5 11
4 y% E6 {. N! }* L+ o6 I( m* ^6 9
7 f/ }. ` W- G* N6 b7 8. }; k) u5 e" \* H# J
;- T, J4 t4 @7 t. ]9 p: {
title ;, H8 o8 E* @9 Z* o) c* g1 P
footnote;( C5 g, h+ u- V; T6 ^! x2 k g
proc sgplot data=ex noautolegend; ^* ~5 e; M! Z) J
SERIES x=x y=y/LINEATTRS=(color=blue thickness=6) ;
/ V+ U7 ~' F- V5 H7 R# |$ Bband x=x lower=0 upper=2.5 / OUTLINE transparency=.8 LINEATTRS=(color=black) fillattrs=(color=cxEEE3B4) NOOUTLINE;
0 g% m2 v4 m# g1 n8 M! `) hband x=x lower=2.5 upper=5 / OUTLINE transparency=.7 LINEATTRS=(color=black) fillattrs=(color=orange) NOOUTLINE;
$ N M% X9 w0 s# qband x=x lower=5 upper=7.5 /OUTLINE transparency=.8 LINEATTRS=(color=black) fillattrs=(color=cxEEE3B4) NOOUTLINE;
0 s' P# a8 V4 S" bband x=x lower=7.5 upper=10 / OUTLINE transparency=.7 LINEATTRS=(color=black) fillattrs=(color=orange) NOOUTLINE;
/ Q! L% J( ^, G6 {band x=x lower=10 upper=12.5 /OUTLINE transparency=.8 LINEATTRS=(color=black) fillattrs=(color=cxEEE3B4) NOOUTLINE; i: w) s* f _6 P3 j
yaxis values=(0 to 12 by 3) min=0 max=13 valueshint;* S7 ~! C: T& }: s7 D
xaxis values=(0 to 8 by 2) min=0 max=8 valueshint;
$ x. w9 {$ \* V/ ~5 Mrun;
' L. j, ]$ o0 A来源:数据挖掘学院 |
zan
|