Earnings Response Coefficient - SAS code
Posted: 25 January 2013 08:40 PM   [ Ignore ]
Newbie
Rank
Total Posts:  22
Joined  2013-01-15

Hi,

Thanks for sharing your code (see below), I have two questions :

http://www.wrds.us/index.php/tutorial/view/18


your code has:

1. key = gvkey || “_” || datadate;

how do you type ||  in Sas?

2. /*let’s keep only those firmquarters that were reported within 90 days after quarter’s end;*/if ((rdq - datadate) <=90);

is it a common practice to use only 90 days after announcement date for analysis, e.g. if I want to examine analyst forecast disperson using quarterly date, should I use 90 days post announcement date ?

Thanks a bunch,

—R

Profile
 
 
Posted: 26 January 2013 01:22 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Rochelle,

The ‘|’ character is right above ‘enter’ on the right side of the keyboard. Hitting shift + ‘\’ will give ‘|’.

I think it is fine to incude all earnings announcements, and not exclude delayed ones. The delayed ones are ‘bad news’, so you may want to keep these in so that you can generalize. You can always do a sensitivity analyses and report if results change or not when excluding these.

Hope this helps,

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: 26 January 2013 02:32 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  22
Joined  2013-01-15

Hi, Joost

Thanks for helping me and so many others !

I am using your post http://www.wrds.us/index.php/tutorial/view/18

to extract IBES data. here is my question: I have a dataset with PERMNO,TICKER,

1. to get compustat earning annoucnement date, I want to following you code (http://www.wrds.us/index.php/tutorial/view/18) to upload my file to wrds server and pull only those with knownPERMNO. Your example used GVKEY. How should I modify your code to pull the matching PERMNO, GVKEY, and/or CUSIP?

2. after I complete 1, I can then link to IBES using IBES.idsum.

- R

Profile
 
 
Posted: 28 January 2013 04:00 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Rochelle,

If I understand correctly, you have a dataset with permno and ticker, and you need to match with Compustat and Ibes.

If that is the case, this is what you could do:
- 1. Identify which variable holds a date, like the end of year, or an event date (I assume you have such a variable and is called RochDate)
- 2. Match with CCM mergetable (assuming you have uploaded your dataset as ‘getThese’), in a rsubmit (I haven’t tested this code):

PROC SQL;
  
create table ccMerged as
  
select a.*, b.gvkey
  from getThese a
crsp.ccmxpf_linktable b
    where a
.permno b.lpermno
    
and ((a.RochDate >= b.LINKDT) or b.LINKDT = .B) and
       ((
a.RochDate <= b.LINKENDDT) or b.LINKENDDT = .E)   ;
  
quit

Then, you can go ahead and match with Ibes as pointed out in the tutorial.

Hope this helps,

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: 28 January 2013 04:34 PM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  22
Joined  2013-01-15

hi, Joost

I just posted a similar question before I saw your response. it is titled “Permno link CRSP to IBES”. I hope you don’t mind.

my data does not have a date variable, but only permno, ticker, COMNAM (CRSP). I basically want to use these firms to study their analyst forecasts.

I do not have access to CCM mergetable.

should I use crsp stockname file to extract ncusip with my permno, However, stockname has NAMEDT NAMEENDDT, should I use those to check if permno changed?

thanks again,

-R

Profile
 
 
Posted: 28 January 2013 08:08 PM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Rochelle,

No problem, I will remove the ‘double’ post.

Have you tried something like this (taken from http://www.wrds.us/index.php/tutorial/view/18):

downloading file for testing/debugging (is not necessarysince the next step is on WRDS also);*/
proc download data=ccMerged out=myLib3.e_ccMerged;
  
/* match with dsenames for historic cusip (NCUSIP) ;*/
  
PROC SQL;
  
create table dsenames as
  
select a.*, b.ncusip
  from ccMerged a
crsp.dsenames b
  where
        a
.lpermno b.PERMNO
    
and b.namedt <= a.datadate <= b.nameendt
    
and b.ncusip ne "";
  
quit;
  
/* downloading file for testing/debugging (is not necessary, since the next step is on WRDS also);*/
proc download data=dsenames out=myLib3.f_dsenames;run;
  
/* match with ibes: Company Identification (idsum)*/
  
PROC SQL;
  
create table ibesdata as
  
select distinct a.*, b.ticker as ibes_ticker
  from dsenames a
ibes.idsum b
  where
        a
.NCUSIP b.CUSIP
    
and a.rdq b.SDATES
;
quit;
proc download data=ibesdata out=myLib3.g_withIbes;
run;
endrsubmit

You have permno, so you can get cusip. With cusip you get ibes ticker. You don’t have ‘datadate’, but it is probably wise to construct some sort of date variable. If you do not match on date, you may get multiple hits for firms that changed cusip over time. Alternatively, you can allow doubles initially, and throw away double records later after matching with ibes.

best regards,

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: 13 April 2015 12:55 AM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  4
Joined  2015-04-13

Hi Joost, thank you for sharing your code. Following the code from this website: http://www.wrds.us/index.php/tutorial/view/estimating_the_earnings_response_coefficient_erc the f,irst error I’ve got was:“File CRSP.CCMXPF_LINKTABLE.DATA does not exist.”
Is the crsp directory ‘/wrds/crsp/sasdata/cc’ updated or changed?

 

Profile
 
 
Posted: 13 April 2015 07:10 AM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Filorga,

That is quite likely; the quickest way to test this is to remove the libname assignment for crsp (so that the default value is used).

Best regards,

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: 13 April 2015 07:16 AM   [ Ignore ]   [ # 8 ]
Newbie
Rank
Total Posts:  4
Joined  2015-04-13

Hi Joost, thank you for your reply. I removed the line “libname crsp ‘/wrds/crsp/sasdata/cc’”, but still got the same error message “File CRSP.CCMXPF_LINKTABLE.DATA does not exist.” :(

Profile
 
 
Posted: 13 April 2015 11:52 AM   [ Ignore ]   [ # 9 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Filorga,

It may be the case that your institution is not subscribed to the ccm linktable (access to many files is sold separately).

This code worked for me:

%let wrds wrds.wharton.upenn.edu 4016;options comamid TCP remote=WRDS;
signon username=_prompt_;

rsubmit;
proc download data=crsp.CCMXPF_LINKTABLE out=work.CCMXPF_LINKTABLE;run;
endrsubmit

After signon, you see the SAS log has the library assignments, search for CRSP, mine is as follows:

Libref CRSP was successfully assigned as follows:
      
Levels:           9
      Engine
(1):        V9
      Physical Name
(1): /wrds/crsp/sasdata/a_stock
      Engine
(2):        V9
      Physical Name
(2): /wrds/crsp/sasdata/a_stock62
      Engine
(3):        V9
      Physical Name
(3): /wrds/crsp/sasdata/a_indexes
      Engine
(4):        V9
      Physical Name
(4): /wrds/crsp/sasdata/a_ccm
      Engine
(5):        V9
      Physical Name
(5): /wrds/crsp/sasdata/a_treasuries
      Engine
(6):        V9
      Physical Name
(6): /wrds/crsp/sasdata/a_treas_bd
      Engine
(7):        V9
      Physical Name
(7): /wrds/crsp/sasdata/a_treas_bm
      Engine
(8):        V9
      Physical Name
(8): /wrds/crsp/sasdata/a_ziman
      Engine
(9):        V9
      Physical Name
(9): /wrds/crsp/sasdata/q_mutualfunds 

Check if yours contains ‘ccm’ (as in the 4th entry). By the way, the crsp libname is indeed broken (’/wrds/crsp/sasdata/cc’ no longer works).

Best regards,

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: 13 April 2015 01:41 PM   [ Ignore ]   [ # 10 ]
Newbie
Rank
Total Posts:  4
Joined  2015-04-13

Dear Joost, thank you! I change the directory to “libname crsp ‘/wrds/crsp/sasdata/a_ccm’ and it works!

Profile
 
 
Posted: 13 April 2015 01:51 PM   [ Ignore ]   [ # 11 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

I’m glad to hear that! smile

Joost

 Signature 

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

Profile