SAS ——VAR的蒙特卡罗估计法及评价
【程序一】
data c;
set sjk7_1a;
sgm=0;
if n <1;
proc means data=sjk7_1a;
output out=c1 mean (r _ log)=m;
data c1;
modify c1;
if n >0 then remove;
data a;
set sjk7_1a;
if date >=19990101;
options nodate nonotes nosource;
%macro zsvar;
%do n =1% to 258;
data b;
set a;
if n <=259;
retain sgm;
if n =1 then sgm=r_log;
else sgm=sqrt(r_log2/16.667+0.94*sgm2);
data b;
modify b;
if n ^=259 then remove;
proc append base=c data=b;
proc means data=a;
output out=b1 mean(r_log)=m;
proc append base=c1 data=b1;
data a;
modify a;
if n =1 then remove;
%end;
%mend zsvar;
%zsvar;
run;
data c2;