Joost Impink - 18 October 2015 02:01 PM

hi,

You can have the #obs used in the regression output, so filtering obs with less than 30 obs you can do after the regression. It will help to have a variable that identifies the right ‘level’ of what you are looking at (in your case: firmyears).

```
data dsEmily;
```

set dsIn;

key = gvkey || fyear; /* will paste gvkey and fyear together */

run;

You can then have a ‘by key’ in your regression.

```
/* needs sorting */
```

proc sort data=dsEmily; by key;run;

proc reg data = dsEmily noprint tableout edf outest = regOutEmily;

by key;

model marktret= ret;

quit;

I didn’t test the regression part, so you may need to google a bit to see how proc reg works. The regOutEmily dataset should have estimated coefficients and #obs.

Best,

Joost

Dear Joost,

Thank you.

I am sorry I didn’t understand your code. So, I create return data table for each year, and calculate alpha and beta for each firm in that year. :(

another question is that the paper said they use 60-month return data before cumulation period to estimate alpha and beta, so i use the following code to define my begindate and enddate:

```
data mylib1.h_estperiod(keep= permco datadate year startdate enddate);
```

set mylib1.e_finalfuda;

startDate = intnx('month', datadate,-68, 'beginning');

endDate = intnx('month', datadate,-8, 'end');

format startDate endDate MMDDYY10.;

run;

Is the code right? I wonder if i need to find out 60 monthly return data observations instead of using month(datadate) minus 60 months? I want to exclude the case that a security is subject to a Trading Pause or something like that which cause the missing of return data.

So, if I want to find out the estimation period defined as 60 monthly return observations prior to the event date, could you please help me with the SAS code?

Thank you again for your patient and great help.

Regards,

Emily