|
|
6#

楼主 |
发表于 2008-7-11 21:36:44
|
只看该作者
Re: 关于sas作图的难题
data Shangzhenzhishu;
input date yymmdd10. Oppr Hipr Lopr Clpr vol;
format date yymmdd10.;
cards;
1990-12-19 96.05 99.98 95.79 99.98 126000
1990-12-20 104.30 104.39 99.98 104.39 19700
1990-12-21 109.07 109.13 103.73 109.13 2800
1990-12-24 113.57 114.55 109.13 114.55 3200
1990-12-25 120.09 120.25 114.55 120.25 1500
1990-12-26 125.27 125.27 120.25 125.27 10000
1990-12-27 125.27 125.28 125.27 125.28 6600
1990-12-28 126.39 126.45 125.28 126.45 10800
1990-12-31 126.56 127.61 126.48 127.61 7800
;
run;
data candles;
length color function style $8;
retain xsys ysys '2' style 'solid' size 1;
set Shangzhenzhishu;
if clpr>oppr then color='red';
else color='green';
/*Draw the open/close box */
function='move'; xsys='2'; ysys='2'; x=date; y=clpr; output;
function='poly'; xsys='7'; ysys='2'; x=+1; y=clpr; output;
function='polycont'; y=oppr; output;
function='polycont'; x=-1; y=oppr; output;
function='polycont'; y=clpr; output;
function='polycont'; x=+0.5; y=clpr; output;
/*Draw high to close and low to open */
if clpr ge oppr then do;
function='move'; xsys='2'; ysys='2'; x=date; y=clpr; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=hipr; output;
function='move'; xsys='2'; ysys='2'; x=date; y=oppr; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=lopr; output;
end;
/* Draw high to open and low to close */
if clpr le oppr then do;
function='move'; xsys='2'; ysys='2'; x=date; y=oppr; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=hipr; output;
function='move'; xsys='2'; ysys='2'; x=date; y=clpr; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=lopr; output;
end;
run;
symbol1 i=none v=none r=2;
axis1 minor=none offset=(5,5)pct;
axis2 label=('Price') minor=none;
title1 '上证综合指数k线图';
/* PROC GPLOT is used as a 'holding' area for the annotate, plus,
gplot */
/* generates the axes. Had to do an overlay plot so that the vertical */
/* axis had the complete range of the data, ie., high to low. */
proc gplot data=Shangzhenzhishu;
plot hipr*date lopr*date / overlay haxis=axis1 vaxis=axis2 anno=candles;
run;
quit;
图作好了,大家细看一下,有没有缺点,我们一起完善,把这个问题深入下去啊,希望大家支持!~ |
|