options nocenter ls=80; *put your directories here; libname temp 'c:\empirical_methods_class\'; filename tempdir 'c:\empirical_methods_class\'; *read ibbotson data; data ibbotson; informat date mmddyy10.; format date mmddyy10.; infile tempdir(stock_bond_data.csv) firstobs=2 dlm=',' missover; input date sp500 small tbill t1yr eqprem tint clong tlong inf; proc print data=ibbotson (obs=100); run; data vx1 (keep=date sp500 tbill); set ibbotson; run; proc means; run; data outdata; do xx=1 to 1; output; end; run; %macro rolling; %do y=1 %to 500; proc surveyselect data=vx1 method=urs n=12 outhits out=vx; run; *proc print data=vx; *run; data vxc (keep=csp500 ctbill); set vx; if _n_=1 then do; csp500=1+sp500/100; ctbill=1+tbill/100; end; else do; csp500=csp500*(1+sp500/100); ctbill=ctbill*(1+tbill/100); end; if _n_=12 then output; retain csp500 ctbill; run; *proc print data=vxc; *run; data outdata; set outdata vxc; run; %end; %mend rolling; %rolling; data outdata; set outdata; drop xx; sp500g=csp500-1; tbillg=ctbill-1; proc means data=outdata n mean std p5 p95; run;