Hi! I have the following code for January that gives me a final table for this month. I need to run this code for all 12 months. Every time I start with a new month I retrieve the information from two datasets; sample_returns and sample_stocks. Since it takes some time so run it all I was wondering if there was a simple loop that I could use to make the process faster. data sample_returns_jan;
set sample_returns;
where month(date)=1;
run;
data sample_stocks_jan;
set sample_stocks;
where month(date)=1;
run;
proc sql;
create table SampleJanuary as
select i.*, cq.date, cq.ret
from sample_stocks_jan i left join sample_returns_jan cq
on i.date = cq.date and i.bucket=cq.bucket and i.permno=cq.permno;
proc sql;
create table sampleJanuary1 as
select i.*, sum(EW*ret) as EW_ret, sum((sqrt(12)*(volatility))*100) as vol_annual,
sum(((1+ret)**12)-1) as ret_annual
from SampleJanuary i
group by month_bucket;
data sampleJanuary1a;
set samplejanuary1;
SP_annual= sum(ret_annual/vol_annual);
by month_bucket;
run;
/*Keeping only the relevant information*/
data final_January;
set sampleJanuary1a;
keep bucket date EW_ret vol_annual SP_annual;
run;
... View more