
Categories
 Data (9)
 Learning Resources (9)
 Python (8)
 SAS (13)
 Stata (26)
Archives
 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)
Category Archives: Stata
How to prevent the “log file already open” error when working with log files in Stata
Sometimes we use the log using filename, replace command at the beginning of a Do file to open a log file and record everything displayed in the Results window. However, if an error interrupts the previous execution of the Do … Continue reading
Stata command to draw a graph showing the average of a variable by group
Suppose we have the following dataset that provides the life expectancy (lexp) of each country in each region: We can draw a bar graph to show the average (or other statistics) life expectancy of each region using two different methods: … Continue reading
Stata command to rename groups of variables
Swap variable names: rename (v1 v2) (v2 v1) Lowercase (or uppercase, or propercase) groups of variable names: rename V1 V2, lower or rename *, lower Add suffix _old to variables v1, v2, … for one or more digits: rename v# … Continue reading
A test on Stata running speed on MacBook Pro (M1 Pro chip) and old Macs
I ran a test on Stata running speed on my newest MacBook Pro (14inch, 2021) and two old Macsâ€”iMac (27inch, 2019) and MacBook Pro (16inch, 2019). Technical specifications: MacBook Pro (14inch, 2021): CPU Apple M1 Pro (10core), memory 16G, SSD … Continue reading
Posted in Stata
6 Comments
Stata command to perform propensity score matching (PSM)
Most propensity score matching (PSM) examples typically use crosssectional data rather than panel data. However, in accounting research, panel data (observations with two subscripts i and t, e.g., firmyears) are often used in a differenceindifferences (DID) research design. This involves … Continue reading
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
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