题目要求如下:This exercise uses the daily US return data in nyseamex d (date, value-weighted index with dividend reinvestment, value-weighted index without dividend reinvestment, equally weighted index with dividend reinvestment, equally weighted index without dividend reinvestment, consumer price index).
要求计算Vt = rtd的平方加总, where rtd is a daily return in month t.
下面是程序:
data ex;
set sasuser.ex3;
rvwd=vwd/lag(vwd)-1;
rvwx=vwx/lag(vwx)-1;
rewd=ewd/lag(ewd)-1;
rewx=ewx/lag(ewx)-1;
run;
proc print data=ex;
run; (此前是一些数据处理,可以忽略)
data ex_1;
input V1;
set ex;
V1=0;
date1=19260101;
date2=19260131;
date3=19261231;
do date=19260102 to 20091231;
V=V1+rvwd*rvwd;
if date>=date1 & date<=date2 then do;
V1=V;
date=date+1;
end;
if date>date2 then output V1;(此处出现错误,说找不到指定数据集。我个人的看法是现在得到的V的观察值和原数据集不匹配,所以发生错误。但是没法解决)
date1=date1+100;
date2=date2+100;
if date2> date3 then do;
date1=date1+8900;
date2=date2+8900;
date3=date3+10000;
end;
end;
run;
求助有关上述问题,如何解决这个错误,或者编一个新的程序也可以,只要可以求出Vt就可以,谢谢啦!凡解决者,必有重奖!