要对10个变量做同样的运算,于是用了array,如下code。可是这段code一旦运行,就不能停止,不能返回exrt数据集,也不报错。
于是用笨办法一个一个的做,出来结果倒是很快。
但是如果变量更多的话,肯定是不能用这个办法的。所以想请大家帮忙看看,我第一段code里面到底有什么问题啊?我是从别的资料里依样画葫芦的。
SAS菜鸟拜谢大家啦。
*/ (1) calculate the excess portfolio returns by subtracting the risk-free rates;
data exrt;
set hw2;
Array ind(10) Nodur -- Other;
Array exrt(10);
DO i = 1 TO 10;
exrt(i) = ind(i) - Rf;
END;
以下只好用笨办法了。
*/ (1) calculate the excess portfolio returns by subtracting the risk-free rates;
data exrt;
set hw2;
Nodur = Nodur - Rf;
Durbl = Durbl - Rf;
Manuf = Manuf - Rf;
Enrgy = Enrgy - Rf;
HiTec = HiTec - Rf;
Telcm = Telcm - Rf;
Shops = Shops - Rf;
Hlth = Hlth - Rf;
Utils = Utils - Rf;
Other = Other - Rf;
drop date rf;
run;