全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
20571 24
2012-12-30
有个说法是如果SAS是AK47,那么EXCEL就是玩具枪。实际应用中我也能感觉到SAS的强大和高效。但不知道为什么,在作图这一块,总感觉SAS太僵化了一些。
例如下面2种图表,我能在EXCEL实现,但不知道如何在SAS中实现,请高手指导,非常感谢!

柱状趋势线图:注意每周里,柱状图是左右放的,而趋势线是上下放的。(似乎SAS无法做到这一点,最多柱状一个胖一个瘦叠在一起)

趋势图:注意同一周不同的点是横着往右走的。 (在SAS里,同一周不同的点是竖着上下放的)

谢谢!
附件列表
overlay.jpg

原图尺寸 131.22 KB

overlay.jpg

barline.jpg

原图尺寸 131.81 KB

barline.jpg

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-12-30 18:24:39
对你的问题不感兴趣,推荐一本书:statistical graphics in sas
只有你想不到的,没有SAS做不到的。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-31 00:10:10
The gbarline can plot bars and line together. Here is an example for your problem.

data trend;
input week        yield        input;
n+1;
if n<=6 then flag='up  ';
else flag='down';
wkflag=catt(week,'_',flag);
if flag='up  ' then yield_up=yield;
else yield_down=yield;
cards;
1        92                360       
2        95                460       
3        81                560       
4        91                360       
5        85                460       
6        90                560       
1        90                644       
2        91                244       
3        78                344       
4        87                544       
5        92                244       
6        88                544       
;
proc print;run;

proc sort data=trend; by week flag; run;

goptions reset=all border;
axis1 label=(j=c  j=c ) minor=none; /* left */
axis2 label=(j=c  j=c  j=c ) minor=none; /* right */
axis3 label=none; /* bottom */
/* Bar legend */
legend1 position=(middle right outside)  across=1
        label=(position=(top )  j=l );
/* Line plot legend */
legend2 position=(bottom right outside) across=1 repeat=1
        label=(position=(top) j=l  "Lines:") ;
symbol1 c=black value=circle;
symbol2 value=dot;
proc gbarline data=trend;
   bar wkflag/ discrete  sumvar=input subgroup=flag
              raxis=axis1 maxis=axis3 legend=legend1
              ;

   plot / sumvar=yield_up    legend=legend2 axis=axis2;
   plot / sumvar=yield_down  legend=legend2 axis=axis2;
run;
quit;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-31 00:33:37
SAS的作图一向不以简洁著称,而是以其全面性,基本可以画任何需要的图形;
而想真正发挥graph的实力,还需要需要学习annote的语法;
倒是SAS不能像R或者matlab那样,能够在画好的图形上进行任何操作,
虽然9.2推出了graphics editor,但是所添的功能也着实有限
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-31 00:38:46
If you have sgplot licensed, it will be much easier.

data trend;
input week        yield        input;
n+1;
if n<=6 then flag='up  ';
else flag='down';

cards;
1        92                360       
2        95                660       
3        81                560       
4        91                360       
5        85                460       
6        90                560       
1        90                644       
2        91                444       
3        78                344       
4        87                544       
5        92                444       
6        88                544       
;
proc print;run;

proc sgplot data=trend;
  vbar week / response=yield group=flag BARWIDTH=0.6
   GROUPDISPLAY= CLUSTER CLUSTERWIDTH=0.8;
  vline week / response=input group=flag  GROUPDISPLAY=OVERLAY  y2axis ;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-31 00:42:23
现有bar-line模块好像不能将柱状图左右放,
用gplot变通一下,可以达到以上的效果:
data ex;
input
week $ yield_up:percent5.1 input_up yield_down:percent5.1 input_down;
format yield_up percent5.1 yield_down percent5.1;
cards;
wk01 92.0% 160 90.0% 644
wk02 93.0% 346 92.0% 740
wk03 94.0% 632 93.0% 230
wk04 95.0% 780 94.0% 173
wk05 95.0% 699 94.0% 173
wk06 96.0% 46  95.0% 151
;
run;
data ex1;
set ex;
n=_n_;
n1=n-0.1;
n2=n+0.1;
run;
proc sql noprint;
select cat('t=',n+1,' ',quote(compress(week))) into:value separated by ' ' from ex1;
quit;

goptions reset=all;
symbol1 i=join v=square c=bule ;
symbol2 i=join v=triangle c=red;
symbol3 i=needle v=none c=black w=30;
symbol4 i=needle v=none c=vibg  w=30;
axis1 offset=(0,0) value=(t=1 "" &value t=8 "") order=(0 to 7 by 1) minor=none label=("Week");
axis2 order=(0.87 to 0.97 by 0.01) minor=none label=("Yield");
axis3 order=(0 to 900 by 100) minor=none label=("Input");
legend1 across=2 down=1 position=(bottom center outside) noframe label=("");
legend2 across=2 down=1 position=(bottom center outside) noframe label=("");
proc gplot data=ex1;
plot yield_up*n1=1 yield_down*n2=2/overlay haxis=axis1 vaxis=axis2 autovref legend=legend1 ;
plot2 input_up*n1=3 input_down*n2=4/overlay legend=legend2 vaxis=axis3;
run;
quit;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群