1) Make a dataset (Key_Table) like :
id start end
1 2004/01/31 2008/12/31
1 2005/01/31 2009/12/31
1 2013/01/31 2017/12/31
2) Make a macro .
%macro estim (id=,start=,end=);
proc reg data =have(where=(id=&id and date between &start and &end)) outest = results ;
model r = rm ;
by firm per ;
quit ;
proc append base = betas1 data = results ;
%end ;
%mend estim ;
3) CALL EXECUTE() to go through.
data _null_;
set Key_Table;
call execute(cats('%estim (id=',id,',start=',start,',end=',end,')'));
run;
... View more