朱世武老师程序中的问题?
/* 产生样本债券SampFbd050131未来现金流与对应的时刻 */
data SampFbd050131;
set ResDat.SampFbd050131;
if freq=0 then _t=Yrstmat+1e-12; else _t=mod(yrdif(date,matdt,'act/act'),1/Freq); /*_t为当前日到下一个付息的时间 */
if mod(_t,1)=0 then do;
_t=_t+1e-12; /* 正好付息日时,因为_t为整数时,包含_t的函数没有结果 */
end;
run;
data tbond_info;
set SampFbd050131;
if freq=0 then do;
t=_t;
output;
end;
else do t=_t to Yrstmat by 1/freq; /* 产生现金流对应的时刻 */
output;
end;
proc sort;
by resbdid;
data tbond_info;
set tbond_info;
if In***=2 and last.resbdid=0 then CF=couprt*par/freq; /*到期日前附息债产生的现金流*/
if In***=2 and last.resbdid=1 then CF=couprt*par/freq+par; /*到期日附息债产生的现金流*/
if In***=0 and last.resbdid=0 then CF=0; /*到期日前贴现债现金流*/
if In***=0 and last.resbdid=1 then CF=par; /*到期日贴现债现金流*/
if In***=1 and last.resbdid=0 then CF=0; /*到期日前零息票债现金流*/
if In***=1 and last.resbdid=1 then CF=par+couprt*par*maturity; /*到期日贴现债现金流*/
by resbdid;
run;
/* 数据集tbond_info增加了3个变量:
_t为当前日到下一个付息的时间
t:现金流发生时间
CF:现金流量 */
问题一:为什么这里if freq=0 then _t=Yrstmat+1e-12; 要加上1e-12?
问题二:by resbdid;是什么意思?
问题三:if In***=2 and last.resbdid=0 then CF=couprt*par/freq; /*到期日前附息债产生的现金流*/ 这一行又是什么意思?