
Categories
 Data (8)
 Learning Resources (11)
 Python (8)
 SAS (13)
 Stata (27)
Archives
 June 2024 (1)
 January 2024 (1)
 September 2023 (1)
 August 2023 (1)
 May 2023 (1)
 February 2022 (2)
 January 2022 (1)
 August 2021 (1)
 September 2019 (1)
 August 2019 (2)
 July 2019 (2)
 May 2019 (1)
 April 2019 (1)
 March 2019 (1)
 August 2018 (3)
 July 2018 (4)
 December 2017 (1)
 November 2017 (1)
 October 2017 (1)
 September 2017 (1)
 April 2017 (2)
 September 2016 (1)
 April 2016 (1)
 December 2015 (1)
 November 2015 (1)
 September 2015 (4)
 August 2015 (5)
 June 2015 (3)
 March 2015 (7)
 February 2015 (2)
Author Archives: Kai Chen
Stata command to perform Chow test
A Chow test is simply a test of whether the coefficients estimated over one group of the data are equal to the coefficients estimated over another. I find two useful articles from Stata’s official website: Can you explain Chow tests? … Continue reading
Posted in Stata
6 Comments
SAS macro to count the number of analysts following a firm
This macro is used to count the number of analysts who followed a specific firm. Although this is a commonly used measure in literature, prior studies often give a vague description on what they do. The question is—what does “analysts … Continue reading
Posted in SAS
2 Comments
Stata command to lowercase all variable names or the values of all string variables
Stata is a casesensitive application, which can sometimes cause trouble. Therefore, we might want to convert all variable names or the values of all string variables to lowercase before further data processing. This post gives a quick method to do … Continue reading
Posted in Stata
2 Comments
Stata command to order tabulation result with only top values shown
tabulate varname command is handy in Stata, but sometimes it returns a too long result, if varname contains too many unique values. The thirdparty command, groups, will solve the problem by showing top values only. Please use ssc install groups … Continue reading
Posted in Stata
Leave a comment
Empower “and” and “or” in IF statement in Stata
Stata is a little bit awkward when using and and or in if statement, compared to SAS. For example: In SAS, we can write if 2001 <= fyear <= 2010. But in Stata, we usually write: if fyear >= 2001 … Continue reading
Display mean and median test results in Stata
Sometimes we may want to produce the following table to compare the mean and median of two groups: First of all, please refer to this post to see Stata commands to test equality of mean and median. However, it is … Continue reading
Posted in Stata
22 Comments
Stata command to do Heckman two steps
We often see Heckman’s two steps in accounting literature. But how to do it in Stata? The two steps refer to the following two regressions: Outcome equation: y = X × b1 + u1 Selection equation: Dummy = Z × … Continue reading
Posted in Stata
9 Comments
The calculation of average credit rating using ratings from three rating agencies
I was doing something in Finance and wanted to calculate the average rounded credit rating. Basically, I need to translate textual grades (e.g., AAA, Baa) to a numerical value. I found a clue in the following paper: Becker, B., and … Continue reading
Stata command to test equality of mean and median
Please read this post for how to display the results in a readyforuse format. UCLA IDRE has posted an article (link) that may provide a bit more explanation. UCLA IDRE is a great resource for learning statistical analysis. A big thank you … Continue reading
Posted in Stata
3 Comments
Stata command to display combined Pearson and Spearman correlation matrix
Oftentimes we would like to display Pearson correlations below the diagonal and Spearman correlations above the diagonal. Two builtin commands, pwcorr and spearman, can do the job. However, we have to manually combine Stata output tables when producing the correlation table … Continue reading