The impact of WRDS transition to the new WRDS Cloud server

WRDS has quietly started the transition from the old server to the new Cloud server. This move makes a lot of support documentation on the WRDS website outdated and misleading. That is why I think WRDS should direct its resources on continuously … Continue reading

Posted in Learning Resources, SAS | 1 Comment

Rolling-window computation in SAS and Stata

SASers often find proc expand plus transformout very useful for rolling-window (or moving-window) computation. Stataers may wonder if there is a counter party in Stata. The answer is “yes”. The command in Stata is rolling. See the manual below: The … Continue reading

Posted in Learning Resources, SAS, Stata | Leave a comment

SAS macro for event study and beta

There are two macros on the List of WRDS Research Macros: EVTSTUDY and BETA, which may be often used. I like the first one, written by Denys Glushkov. Denys’ codes are always elegant. I don’t like the second one because … Continue reading

Posted in SAS | 1 Comment


These are some topics in my mind. I will write up when I have time. Use Python to remove boilerplate paragraph in firm-initiated press releases Calculate earnings surprises Chow test and Vuong test Access to WRDS Propensity score matching macros … Continue reading

Posted in Uncategorized | Leave a comment

Use Python to calculate the tone of financial texts

I find two internet resources for this task (thank both authors): The first solution is way more efficient than the second, but the second is more straightforward. The first needs extra knowledge of PostgreSQL and R besides Python. I … Continue reading

Posted in Python | 5 Comments

How to remove duplicate GVKEY-DATADATE when using Compustat Annual (FUNDA) and Quarterly (FUNDQ)?

The annual data is easy to deal with, you just need to add conditions as follows: indfmt==”INDL” & datafmt==”STD” & popsrc==”D” & consol==”C” If you have downloaded FUNDA and converted it into Stata format, the uniqueness of GVKEY-DATADATE can be … Continue reading

Posted in Learning Resources | 4 Comments

If beginning year and ending year are known, how to fill in years in between?

Question: Suppose two companies A and B are connected in some years. Say, right now the data structure is the following: Company 1 Company 2 Starting Year Ending Year A B 2000 2006 A C 1998 2003 C D 1995 … Continue reading

Posted in SAS | Leave a comment

SAS macro to get analysts EPS consensus for a given fiscal period end (DATADATE) by a selected date (DATE)

I write this macro to compute analysts’ quarterly EPS consensus on a selected date (DATE) for a given fiscal quarter end (DATADATE). This macro can be easily modified for other types of estimates (e.g., annual EPS). This macro currently extracts unadjusted quarterly EPS estimates (current … Continue reading

Posted in SAS | Comments Off on SAS macro to get analysts EPS consensus for a given fiscal period end (DATADATE) by a selected date (DATE)

Link Audit Analytics, Compustat, CRSP and I/B/E/S

The following program is used to link each financial restatement in Audit Analytics to Compustat, CRSP, and I/B/E/S. The resultant dataset aa contains unique identifiers of Audit Analytics (res_notify_key), Compustat (gvkey), CRSP (permno), and I/B/E/S (ibtic). Please note this program … Continue reading

Posted in SAS | 12 Comments

Regression with a large dummy-variable set (e.g., firm and year fixed effects) in Stata

I run a regression in Stata with a Compustat dataset that contains fyear and gvkey. I want to add firm and year fixed effects, so I type the following command: regress DV IV i.fyear i.gvkey But Stata returns the error … Continue reading

Posted in Stata | Leave a comment