Search

how to calculate the estimation period
 Posted: 18 October 2015 02:53 AM [ Ignore ]
Newbie
Total Posts:  14
Joined  2014-11-08

Dear All,

I am new here and a newbie to SAS. I want to calculate the estimation period using SAS. My estimation period is 12 months extending from 9 months prior to fiscal year end to 3 months after it. Since companies have different fiscal year end, I don’t know how to calculate the estimation period for all companies. Could anybody please give me a hand? Thanks.

Regards,
Emily

 Profile

 Posted: 18 October 2015 07:29 AM [ Ignore ]   [ # 1 ]
Total Posts:  901
Joined  2011-09-19

hi Emily,

The intnx function is useful for this: http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p10v3sa3i4kfxfn1sovhi5xzxh8n.htm

``` data dsOut; set dsIn; /* this will set boy to 9 months before datadate (‘b’ will give first day of 8 months before, so effectively 9 months */ startDate = intnx(‘month’, datadate,-8, ‘b’); /* using ‘e’, it will be the last day of the month; in this case last day of 3 months after datadate */ endDate = intnx(‘month’, datadate, 3, ‘e’); /* date variables need formatting for humans */ format startDate endDate date9.; run; ```

``` Best, Joost```
```  Signature  To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas ```
 Profile

 Posted: 18 October 2015 12:03 PM [ Ignore ]   [ # 2 ]
Newbie
Total Posts:  14
Joined  2014-11-08
Joost Impink - 18 October 2015 07:29 AM

hi Emily,

The intnx function is useful for this: http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p10v3sa3i4kfxfn1sovhi5xzxh8n.htm

``` data dsOut; set dsIn; /* this will set boy to 9 months before datadate (‘b’ will give first day of 8 months before, so effectively 9 months */ startDate = intnx(‘month’, datadate,-8, ‘b’); /* using ‘e’, it will be the last day of the month; in this case last day of 3 months after datadate */ endDate = intnx(‘month’, datadate, 3, ‘e’); /* date variables need formatting for humans */ format startDate endDate date9.; run; ```

``` Best, Joost ```
``` Dear Joost, Thank you so much. I am replicating a paper published in 1993, and struggling with it. Now I need to calculate abnormal return in the estimation period. The period is 60-month proceeding the cumulation period which is defined as 9 months prior to fiscal year end. I have two dataset: one contains permco, datadate, fiscal year end, startdate, and enddate; the other contains permco, date, ret, marktret. I have two problems here. First, I want to count the observation of return data for each firm in each year, because I want to whether the period is enough to estimate expected return (alpha, beta); Second, if the period is enough, such as more than 30 months, I want to regress the ret on markeret according to the startdate and enddate in different files. Since I am a master student and not familiar with SAS, could you please give me a hand? Thank you. Enclosed is the screenshot for the data. Regards, Emily    ```
``` Image Attachments Click thumbnail to see full-size image ```
 Profile

 Posted: 18 October 2015 02:01 PM [ Ignore ]   [ # 3 ]
Total Posts:  901
Joined  2011-09-19

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

Signature

 Profile

 Posted: 18 October 2015 10:59 PM [ Ignore ]   [ # 4 ]
Newbie
Total Posts:  14
Joined  2014-11-08
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

 Profile

 Posted: 19 October 2015 07:04 AM [ Ignore ]   [ # 5 ]
Total Posts:  901
Joined  2011-09-19

hi Emily,

The code looks good to me; inspecting the data will tell I suppose if it is indeed 68 months before the end of year.

Firms that are temporarily listed on otc/pink sheets will have missing returns on crsp.msf, and will introduce some noise (I believe the missing part is included in the follow up month when listed again at the ‘normal’ exchange). I doubt if this is really something you need to worry about.

Best,

Joost

Signature