Hi I'm pretty sure my code is completely wrong. I'm try to run a macro that performs an event study when firms are included into a portfolio and then removed to measure the average change in the model coefficients. Here I've tried to look at just the inclusion. When I run the macro I get the errors:
Apparent symbolic reference I not resolved, The %DO statement is not valid in open code**.
I suspect there must be some major flaws in here.
Any advise would be appreciated and if anyone could point to a good online guide that would also be fantastic.
%macro estudy(ds=var1,subgroup=evntdum);
%let evntdays=%eval(&end-&start+1);
/date counter and split data and event periods/
data estper evntper;
merge &ds (drop=before) n&ds;
by firm evntdate;
if first.evntdate then relday=-before_sum - 1;
relday + 1;
if relday <-30 then output estper;
if &start <= relday <= &end then output evntper;
run;
/* model parameters in estimation period/take out firm. non port are weighted returns not in the portfolio. I exclude each firm for its inclusion event.*/
proc reg data=estper outest=mmparam (rename=(intercept=alpha port_ret=beta1 Non_port_ret=beta2)
keep=asx evntdate intercept asx200_ret non_asx200_ret) noprint;
by asx evntdate;
model var1(firm ret)= asx200_ret (non_asx200_ret-weighted_ret(var1));
quit;
proc reg data=evntper outest=afiparam (rename=(intercept=alpha port_ret=beta1 Non_port_ret=beta2);
keep=firm evntdate intercept port_ret non_prt_ret) noprint;
by firm evntdate;
model var1(firm ret)= (port_ret-weighted_ret(var1)) non_firm_ret;
quit;
run;
%mend estudy;
Then calling the macro with:
/* one day stats */
%evntrun(dataset=libref.dset,portf=evntdum);
%do i=0 %to 0;
%let start=&i;
%let end=&i;
%estudy(ds=&dataset,subgroup=&portf)
%end;
/*multiday statistics */
%let start = -120;
%let start = 180;
%estudy(ds=&dataset,subgroup=&portf);
%mend evntrun;
/* run program */
%evntrun(ds=&dataset,subgroup=&portf);
The error messages about %do statement and &i not resolving are because you have forgotten the %MACRO statement and the start of the definition of %evntrun. It should be:
%macro evntrun(dataset=libref.dset,portf=evntdum) ;
There may be other issues as well. Would suggest making &start and &end parameters to %estudy.