Categories
 Data (8)
 Learning Resources (8)
 Python (8)
 SAS (13)
 Stata (22)
 Uncategorized (1)

Recent Posts
Recent Comments
 Victor Wang on Use Python to download TXTformat SEC filings on EDGAR (Part I)
 Kai Tham on Use Python to download TXTformat SEC filings on EDGAR (Part I)
 Arthur Morris on Stata command to create FamaFrench industry classifications based on SIC codes
 Jiadi on Use Python to extract URLs to HTMLformat SEC filings on EDGAR
 Yuchen on How to remove duplicate GVKEYDATADATE when using Compustat Annual (FUNDA) and Quarterly (FUNDQ)?
Archives
Meta
Category Archives: Stata
Stata command to calculate the area under ROC curve
If we want to evaluate the predictive ability of a logit or probit model, Kim and Skinner (2012, JAE, Measuring securities litigation risk) suggest that A better way of comparing the predictive ability of different models is to use the Receiver … Continue reading
Stata commands to calculate skewness
Suppose we are going to calculate the skewness of 12 monthly returns. The 12 returns may be stored in a row (Figure 1) or in a column (Figure 2). This post discusses how to calculate the skewness in these two … Continue reading
Posted in Stata
Leave a comment
Commonly used Stata commands to deal with potential outliers
In accounting archival research, we often take it for granted that we must do something to deal with potential outliers before we run a regression. The commonly used methods are: truncate, winsorize, studentized residuals, and Cook’s distance. I discuss in … Continue reading
Posted in Stata
4 Comments
Sample code for “outreg” command in Stata
outreg is a timesaving and musthave command in Stata. It will generate a readyforuse results table like this. I’m sure you will see what a relief this can give us. outreg is not a builtin command and can be installed … Continue reading
Posted in Stata
Leave a comment
A loop of crosssectional regressions for calculating abnormal accruals in Stata
I write a loop of crosssectional 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
Rollingwindow computation in SAS and Stata
SASers often find proc expand plus transformout very useful for rollingwindow (or movingwindow) 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: http://www.stata.com/manuals13/tsrolling.pdf The … Continue reading
Posted in Learning Resources, SAS, Stata
Leave a comment
How to remove duplicate GVKEYDATADATE 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 GVKEYDATADATE can be verified using … Continue reading
Posted in Data, Stata
12 Comments
Regression with a large dummyvariable 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 FamaFrench industry classifications based on SIC codes
See ffind written by Judson Caskey. Here is his website: https://sites.google.com/site/judsoncaskey/data 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
21 Comments
Fuzzy match in Stata
Nice article. http://ebpprojects.isr.umich.edu/NCRN/papers/wasi_flaaen_statarecordlinkageutilities.pdf Author’s website: http://wwwpersonal.umich.edu/~nwasi/programs.html For installation, type the following command in Stata: net from http://wwwpersonal.umich.edu/~nwasi/programs 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 http://www.statajournal.com/software/sj153 net … Continue reading
Posted in Stata
2 Comments