全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1511 1
2009-09-10
朱世武老师程序中的问题?
/* 产生样本债券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;  /*到期日前附息债产生的现金流*/ 这一行又是什么意思?
二维码

扫码加我 拉你入群

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

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

全部回复
2009-9-11 10:19:24
如果你连set datset;by variable中的by意思都不知道,你最好还是先看看base sas.
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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