Category Archives: Stata

A loop of cross-sectional regressions for calculating abnormal accruals in Stata

I write a loop of cross-sectional regressions for calculating abnormal accruals. This program can be easily modified and replaced with Jones, modified Jones, or Dechow and Dichev model. I add detailed comments in the program to help you prepare the input … Continue reading

Posted in Stata | 7 Comments

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

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

The annual data (FUNDA) is easy to deal with, we just need to apply the following conditions: indfmt==”INDL” & datafmt==”STD” & popsrc==”D” & consol==”C” If we have converted FUNDA to Stata format, the uniqueness of GVKEY-DATADATE can be verified using … Continue reading

Posted in Data, Stata | 10 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

Stata command to create Fama-French industry classifications based on SIC codes

See ffind written by Judson Caskey. Here is his website: The syntax is as follows (download Help file here): ffind sic, newvar(ffi) type(30) type(30) means Fama_French 30 industries classification. Type must be 5, 10, 12, 17, 30, 38, 48 or … Continue reading

Posted in Stata | 17 Comments

Fuzzy match in Stata

Nice article. Author’s website: For installation, type the following command in Stata: net from net install stnd_compname.pkg Update on August 30, 2018—The foregoing URLs seem broken. Please use the following command to install the package: net from net … Continue reading

Posted in Stata | 2 Comments

Calculate CFO tenure with Execucomp in Stata

Nice article and nice blog! Happy to find that someone built a similar blog.

Posted in Stata | 1 Comment

Which is better for archival accounting research, SAS or Stata?

The short answer is: we need both. When we do archival accounting research, we often need to merge data across various databases, such as COMPUSTAT, CRSP, and EXECUCOMP. Stata can by no means beat SAS in this regard. SAS supports … Continue reading

Posted in Learning Resources, SAS, Stata | 1 Comment