-
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
Unlocking the black box: how to calculate book-to-market?
The book-to-market ratio (BM) is one of the most frequently calculated variables in accounting research and is usually used as a control variable in regressions. However, how to calculate it is a question I often asked when I started my … Continue reading
Display full variable names in State Results window
In State, the default width for displaying variable names in the Results window is set to 12. Sometimes it can be frustrating not to see the full variable names. Consider the following results from the tabstat command: Ideally, we’d prefer … Continue reading
Posted in Stata
Leave a comment
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
Link FactSet and CRSP
Both FactSet and CRSP offer identifier files that contain primary identifiers at the entity level and security level (note: an entity may issue multiple securities). These files provide a mapping between their primary identifiers and all other historical identifiers such … 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 (14-inch, 2021) and two old Macs—iMac (27-inch, 2019) and MacBook Pro (16-inch, 2019). Technical specifications: MacBook Pro (14-inch, 2021): CPU Apple M1 Pro (10-core), memory 16G, SSD … Continue reading
Posted in Stata
6 Comments
My thoughts on Python for accounting research
There is a temptation for accounting PhD students to invest in learning Python. However, I would recommend that accounting PhD students focus more on SAS + Stata than on Python in their first year for a few practical and technical … Continue reading
Stata command to perform propensity score matching (PSM)
Most propensity score matching (PSM) examples typically use cross-sectional data rather than panel data. However, in accounting research, panel data (observations with two subscripts i and t, e.g., firm-years) are often used in a difference-in-differences (DID) research design. This involves … Continue reading
Clean up TRACE Enhanced dataset
WRDS provides an excellent manual (link) and SAS code (link) for cleaning up the raw TRACE Enhanced bond transaction data, primarily based on the work done by Dick‐Nielsen, Jens, How to Clean Enhanced TRACE Data (December 3, 2014). Available at … Continue reading
Posted in SAS
Leave a comment