全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1867 2
2010-07-09
悬赏 1 个论坛币 已解决
请见链接:
http://www.pinggu.org/bbs/thread-850324-1-1.html
网论坛里高手能帮忙解决,谢谢!

最佳答案

pobel 查看完整内容

data have; input obs close MA own buy sell; datalines; 1 99.98 1000000 0 0 0 2 104.39 1000000 0 0 0 3 109.13 1000000 0 0 0 4 114.55 1000000 0 0 0 5 120.25 109.66 1 1 0 6 125.27 114.718 1 0 0 7 125.28 118.896 1 0 0 8 126.45 122.36 1 0 0 9 127.61 124.972 1 0 0 10 128.84 126.69 1 0 0 11 130.14 127.664 1 0 0 12 131.44 128.896 1 0 0 ; run; data result; set ha ...
二维码

扫码加我 拉你入群

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

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

全部回复
2010-7-9 09:13:13
data have;
input obs close   MA    own    buy   sell;
datalines;
1  99.98 1000000 0 0 0
2  104.39 1000000 0 0 0
3  109.13 1000000 0 0 0
4  114.55 1000000 0 0 0
5  120.25 109.66 1 1 0
6  125.27 114.718 1 0 0
7  125.28 118.896 1 0 0
8  126.45 122.36 1 0 0
9  127.61 124.972 1 0 0
10  128.84 126.69 1 0 0
11  130.14 127.664 1 0 0
12  131.44 128.896 1 0 0
;
run;

data result;
  set have;
if obs<5 then money=100;
retain last_money;
lag_money=lag(money);
lag_close=lag(close);
lag_own=lag(own);
if lag_money ne . then last_money=lag_money;
if obs>=5 and buy=1 then money=last_money;
if obs>=5 and sell=1 then money=last_money*close/lag_close;
if obs>=5 and buy=0 and sell=0 and lag_own=1 then money=last_money*close/lag_close;
if obs>=5 and buy=0 and sell=0 and lag_own=0 then money=last_money;
last_money=money;
drop lag: last:;
run;
二维码

扫码加我 拉你入群

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

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

2010-7-9 10:48:19
2# pobel
经检验,您的编程过程是完全正确的!感谢您不厌其烦的两次赐教,受益匪浅啊!
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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