这是接在上次修改的后面部分
data w1;
set bonds040927 end=end;
Dur1=1/(dur**0.5);/*权重设为久期的算术平方根的倒数*/
sumDur1+Dur1;
if end;
call symput('ddd',sumDur1);
data w1(keep=w1);
merge bonds040927 w1;
w1=(1/(dur**0.5)/&ddd);
run;
proc iml;
reset deflib=work;
use bonds040927;
read all var{Cldirpr} into Cldirpr;
read all var{Dur} into Dur;
use float_time;
read all var('c1': 'c38') into float;
read all var('t1': 't38') into time;
use w1;
read all var{w1} into wei;
store Cldirpr Dur float time wei;
run;
quit;
proc iml;
reset deflib=work;
use bonds040927;
read all var{Cldirpr} into Cldirpr;
read all var{Dur} into Dur;
use float_time;
read all var('c1': 'c38') into float;
read all var('t1': 't38') into time;
use w1;
read all var{w1} into wei;
store Cldirpr Dur float time wei;
run;
quit;
proc iml;
reset deflib=work;
load Cldirpr Dur float time wei;
y=j(1099560,7);
A=j(38,1,1.);
do b1=-0.086 to -0.076 by 0.001;
do b2=-0.109 to -0.098 by 0.001;
do b0=0.086 to 0.094 by 0.0005;
do t1=9 to 12 by 0.5;
do b3=0.042 to 0.054 by 0.002;
do t2=2.2 to 4 by 0.2;
i=(b1+0.086)/0.001*99960+(b2+0.109)/0.001*8330+(b0-0.086)/0.0005*490+(t1-9)/0.5*70+(b3-0.042)/0.002*10+(t2-2.2)/0.2+1;
y[i,1]=b1;end; y[i,2]=b2;end; y[i,3]=b0;end; y[i,4]=b3;end; y[i,5]=t1;end; y[i,6]=t2;end;
y[i,7]=ssq((((float#exp(-time#(b0+(b1+b2)#((1-exp(-time/t1))/(time/t1))-b2#exp(-time/t1)+b3#((1-exp(-time/t2))/(time/t2)-exp(-time/t2)))))*A-Cldirpr)#wei)/22);
create yyy from y;
append from y;
quit;
proc sort data=yyy;
by col7;
run;
quit;
else do;
y=int(yrdif)*2+1;
a=coupond/2;
end;
array c{38};
do i=1 to y;
if i<y then c[i]=a;
else c[i]=a+100;
end;
do j=y+1 to 38;
c[j]=0;
end;
run;
/* 现金流对应的时刻 */
data time(keep=bdname t1-t38);
set bonds040927;
sdate='27sep2004'd;
edate=Matdt;
yrdif=yrdif(sdate, edate, '30/360');
dif=yrdif-int(yrdif);
if Freq=1 then if dif=0 then do;
y=yrdif;
a=1;
end;
else do;
y=int(yrdif)+1;
a=dif;
end;
if Freq=2 then if dif=0.5 then do;
y=yrdif*2;
a=0.5;
end;
else if dif>0.5 then do;
y=int(yrdif)*2+2;
a=dif-0.5;
end;
else do;
y=int(yrdif)*2+1;
a=dif;
end;
array t{38};
do i=1 to y;
t[i]=a+(1/Freq)*(i-1);
end;
do j=y+1 to 38;
t[j]=1;
end;
run;
data float_time;
merge float time;
run;
/*计算权重*/
data weight;
set bonds040927 end=end;
Dur1=1/Dur;
sumDur1+Dur1;
if end;
call symput('ddd',sumDur1);
data weight(keep=weight);
merge bonds040927 weight;
weight=(1/Dur/&ddd);
run;
data w1;
set bonds040927 end=end;
Dur1=1/(dur**0.5);/*权重设为久期的算术平方根的倒数*/
sumDur1+Dur1;
if end;
call symput('ddd',sumDur1);
data w1(keep=w1);
merge bonds040927 w1;
w1=(1/(dur**0.5)/&ddd);
run;
proc iml;
reset deflib=work;
use bonds040927;
read all var{Cldirpr} into Cldirpr;
read all var{Dur} into Dur;
use float_time;
read all var('c1': 'c38') into float;
read all var('t1': 't38') into time;
use w1;
read all var{w1} into wei;
store Cldirpr Dur float time wei;
run;
quit;
proc iml;
reset deflib=work;
use bonds040927;
read all var{Cldirpr} into Cldirpr;
read all var{Dur} into Dur;
use float_time;
read all var('c1': 'c38') into float;
read all var('t1': 't38') into time;
use w1;
read all var{w1} into wei;
store Cldirpr Dur float time wei;
run;
quit;
proc iml;
reset deflib=work;
load Cldirpr Dur float time wei;
y=j(1099560,7);
A=j(38,1,1.);
do b1=-0.086 to -0.076 by 0.001;
do b2=-0.109 to -0.098 by 0.001;
do b0=0.086 to 0.094 by 0.0005;
do t1=9 to 12 by 0.5;
do b3=0.042 to 0.054 by 0.002;
do t2=2.2 to 4 by 0.2;
i=(b1+0.086)/0.001*99960+(b2+0.109)/0.001*8330+(b0-0.086)/0.0005*490+(t1-9)/0.5*70+(b3-0.042)/0.002*10+(t2-2.2)/0.2+1;
y[i,1]=b1;end; y[i,2]=b2;end; y[i,3]=b0;end; y[i,4]=b3;end; y[i,5]=t1;end; y[i,6]=t2;end;
y[i,7]=ssq((((float#exp(-time#(b0+(b1+b2)#((1-exp(-time/t1))/(time/t1))-b2#exp(-time/t1)+b3#((1-exp(-time/t2))/(time/t2)-exp(-time/t2)))))*A-Cldirpr)#wei)/22);
create yyy from y;
append from y;
quit;
proc sort data=yyy;
by col7;
run;
quit;
把下面这段删掉就行了
*计算权重*/
data weight;
set bonds040927 end=end;
Dur1=1/Dur;
sumDur1+Dur1;
if end;
call symput('ddd',sumDur1);
data weight(keep=weight);
merge bonds040927 weight;
weight=(1/Dur/&ddd);
run;
else do;
y=int(yrdif)*2+1;
a=coupond/2;
end;
array c{38};
do i=1 to y;
if i<y then c[i]=a;
else c[i]=a+100;
end;
do j=y+1 to 38;
c[j]=0;
end;
run;
/* 现金流对应的时刻 */
data time(keep=bdname t1-t38);
set bonds040927;
sdate='27sep2004'd;
edate=Matdt;
yrdif=yrdif(sdate, edate, '30/360');
dif=yrdif-int(yrdif);
if Freq=1 then if dif=0 then do;
y=yrdif;
a=1;
end;
else do;
y=int(yrdif)+1;
a=dif;
end;
if Freq=2 then if dif=0.5 then do;
y=yrdif*2;
a=0.5;
end;
else if dif>0.5 then do;
y=int(yrdif)*2+2;
a=dif-0.5;
end;
else do;
y=int(yrdif)*2+1;
a=dif;
end;
array t{38};
do i=1 to y;
t[i]=a+(1/Freq)*(i-1);
end;
do j=y+1 to 38;
t[j]=1;
end;
run;
data float_time;
merge float time;
run;
data w1;
set bonds040927 end=end;
Dur1=1/(dur**0.5);/*权重设为久期的算术平方根的倒数*/
sumDur1+Dur1;
if end;
call symput('ddd',sumDur1);
data w1(keep=w1);
merge bonds040927 w1;
w1=(1/(dur**0.5)/&ddd);
run;
proc iml;
reset deflib=work;
use bonds040927;
read all var{Cldirpr} into Cldirpr;
read all var{Dur} into Dur;
use float_time;
read all var('c1': 'c38') into float;
read all var('t1': 't38') into time;
use w1;
read all var{w1} into wei;
store Cldirpr Dur float time wei;
run;
quit;
proc iml;
reset deflib=work;
load Cldirpr Dur float time wei;
y=j(1099560,7);
A=j(38,1,1.);
do b1=-0.086 to -0.076 by 0.001;
do b2=-0.109 to -0.098 by 0.001;
do b0=0.086 to 0.094 by 0.0005;
do t1=9 to 12 by 0.5;
do b3=0.042 to 0.054 by 0.002;
do t2=2.2 to 4 by 0.2;
i=(b1+0.086)/0.001*99960+(b2+0.109)/0.001*8330+(b0-0.086)/0.0005*490+(t1-9)/0.5*70+(b3-0.042)/0.002*10+(t2-2.2)/0.2+1;
y[i,1]=b1;
end;
y[i,2]=b2;
end;
y[i,3]=b0;
end;
y[i,4]=b3;
end;
y[i,5]=t1;
end;
y[i,6]=t2;
end;
y[i,7]=ssq((((float#exp(-time#(b0+(b1+b2)#((1-exp(-time/t1))/(time/t1))-b2#exp(-time/t1)+b3#((1-exp(-time/t2))/(time/t2)-exp(-time/t2)))))*A-Cldirpr)#wei)/22);
create yyy from y;
append from y;
quit;
proc sort data=yyy;
by col7;
run;
quit;
proc printto print='d:\shuchu.et';
proc print data=yyy;
run;
else do;
y=int(yrdif)*2+1;
a=coupond/2;
end;
array c{38};
do i=1 to y;
if i<y then c[i]=a;
else c[i]=a+100;
end;
do j=y+1 to 38;
c[j]=0;
end;
run;
/* 现金流对应的时刻 */
data time(keep=bdname t1-t38);
set bonds040927;
sdate='27sep2004'd;
edate=Matdt;
yrdif=yrdif(sdate, edate, '30/360');
dif=yrdif-int(yrdif);
if Freq=1 then if dif=0 then do;
y=yrdif;
a=1;
end;
else do;
y=int(yrdif)+1;
a=dif;
end;
if Freq=2 then if dif=0.5 then do;
y=yrdif*2;
a=0.5;
end;
else if dif>0.5 then do;
y=int(yrdif)*2+2;
a=dif-0.5;
end;
else do;
y=int(yrdif)*2+1;
a=dif;
end;
array t{38};
do i=1 to y;
t[i]=a+(1/Freq)*(i-1);
end;
do j=y+1 to 38;
t[j]=1;
end;
run;
data float_time;
merge float time;
run;
data w1;
set bonds040927 end=end;
Dur1=1/(dur**0.5);/*权重设为久期的算术平方根的倒数*/
sumDur1+Dur1;
if end;
call symput('ddd',sumDur1);
data w1(keep=w1);
merge bonds040927 w1;
w1=(1/(dur**0.5)/&ddd);
run;
proc iml;
reset deflib=work;
use bonds040927;
read all var{Cldirpr} into Cldirpr;
read all var{Dur} into Dur;
use float_time;
read all var('c1': 'c38') into float;
read all var('t1': 't38') into time;
use w1;
read all var{w1} into wei;
store Cldirpr Dur float time wei;
run;
quit;
proc iml;
reset deflib=work;
load Cldirpr Dur float time wei;
y=j(1099560,7);
A=j(38,1,1.);
do b1=-0.086 to -0.076 by 0.001;
do b2=-0.109 to -0.098 by 0.001;
do b0=0.086 to 0.094 by 0.0005;
do t1=9 to 12 by 0.5;
do b3=0.042 to 0.054 by 0.002;
do t2=2.2 to 4 by 0.2;
i=(b1+0.086)/0.001*99960+(b2+0.109)/0.001*8330+(b0-0.086)/0.0005*490+(t1-9)/0.5*70+(b3-0.042)/0.002*10+(t2-2.2)/0.2+1;
y[i,1]=b1;
end;
y[i,2]=b2;
end;
y[i,3]=b0;
end;
y[i,4]=b3;
end;
y[i,5]=t1;
end;
y[i,6]=t2;
end;
y[i,7]=ssq((((float#exp(-time#(b0+(b1+b2)#((1-exp(-time/t1))/(time/t1))-b2#exp(-time/t1)+b3#((1-exp(-time/t2))/(time/t2)-exp(-time/t2)))))*A-Cldirpr)#wei)/22);
create yyy from y;
append from y;
quit;
proc sort data=yyy;
by col7;
run;
quit;
proc printto print='d:\shuchu.xls';
proc print data=yyy(obs=10) noobs;
run;
那个输出太多了,输出十个就行!