全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2467 11
2010-08-26
各位高手...我完成就一個程序..
可惜每次只能走到一個數值的數據...
請問各位如何一次run出幾組不同數值的數據呢?

(因程序太長..所以只發一點...望大家見諒..)



data data;  
input yr y;  /*Input the Year and the Variables*/
cards;
1988 55
1989 70
1990 90
run;

%let f=0.7;  /* Input the Value.(0<=F<=.99)*/   <<~~就是想run後出幾種不同的數值...例如同時run到...0.2..0.5..等等...

data addyr;
set data end=end;
output;
if end then do until(yr=2000);  /*Add the End Year.*/
yr+1;  y=.;
output;
end;
run;

data Q1;
set  addyr;
retain ytop 0;
if _n_=1 then ytop=y;
else do;
f=&f;   
ytop=ytop*(1-f)+y;
end;
aaa=0; ybar=0;
do m=1 to _n_;
f=&f;  
aa= (1-f)**(m-1);
aaa=aa+aaa;   
end;
ybar=ytop/aaa;
run;


謝謝大家的幫忙。
二维码

扫码加我 拉你入群

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

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

全部回复
2010-8-26 15:14:52
data Q1;
set  addyr;
retain ytop 0;
do f=0.2,0.5,0.7;
        if _n_=1 then ytop=y;
        else do;
                ytop=ytop*(1-f)+y;
        end;
        aaa=0; ybar=0;
        do m=1 to _n_;
                aa= (1-f)**(m-1);
                aaa=aa+aaa;   
        end;
                ybar=ytop/aaa;
output;
end;

run;
二维码

扫码加我 拉你入群

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

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

2010-8-26 15:30:22
不好意思呢...
我的程序有數十個 data..
我都是用%let 來輸入要走的數值...
請問有方法只輸入一次數值..便能導入至各data內嘛..?
謝謝你..!!!!!
二维码

扫码加我 拉你入群

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

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

2010-8-26 15:33:04
{:3_41:}好多字不认识啊,看来得回去补习了
二维码

扫码加我 拉你入群

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

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

2010-8-26 15:35:00
pandayan 发表于 2010-8-26 15:30
不好意思呢...
我的程序有數十個 data..
我都是用%let 來輸入要走的數值...
請問有方法只輸入一次數值..便能導入至各data內嘛..?
謝謝你..!!!!!
没看明白
二维码

扫码加我 拉你入群

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

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

2010-8-26 15:42:51
5# pobel

我再表達清楚吧...假如我利用 do f=0.2,0.5,0.7;
我要在每一個位置都要輸入數據..很不方便..(即 data q1及 data q3)
所以我想問.....有冇有一個方法是可以只輸入一次數值便能生成答案呢??
謝謝..


%let f=0.9;  /* Input the Value.(0<=F<=.99)*/


data addyr;
set data end=end;
output;
if end then do until(yr=2005);  /*Add the End Year.*/
yr+1;  y=.;
output;
end;
run;

data Q1;
set  addyr;
retain ytop 0;
if _n_=1 then ytop=y;
else do;
f=&f;   
ytop=ytop*(1-f)+y;
end;
aaa=0; ybar=0;
do m=1 to _n_;
f=&f;  
aa= (1-f)**(m-1);
aaa=aa+aaa;   
end;
ybar=ytop/aaa;
run;

data Q2;
set Q1;
retain  r1 0;   
r1=lag(ybar);
r=ybar/r1;
run;

data Q3;
set  Q2;
retain rtop 0;
if _n_=2 then rtop=r;
else do;
f=&f;   
rtop=(1-f)*rtop+r;
end;
aaa=0; rbar=0;
do m=2 to _n_;
f=&f;  
aa= (1-f)**(m-2);
aaa=aa+aaa;   
end;
rbar=rtop/aaa;
run;
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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