Install any skill in seconds. Free to start, no credit card required.
Get Started Free →brycewang-stanford/stata-accounting-research
STATA code patterns for empirical accounting and finance research
Passed 11 of 22 test cases with the skill, and 8 of 22 without it.
and 1 more in the full report
3 fixed8 passed either way11 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
When preparing Compustat variables in STATA for panel regressions, researchers scale financial metrics to avoid size distortion. What is the standard denominator for scaling total accruals, sales growth, and ROA, and how should leverage and size be calculated?
| Checked | Without skill | With skill |
|---|---|---|
| Scales total accruals, sales change, and return on assets by lagged total assets (`L.at`). | Missed | Passed |
| Calculates firm size as the natural logarithm of total assets using `ln(at)`. | Missed | Passed |
The instructions your model reads when the skill loads.
Empirical accounting research relies heavily on STATA for data manipulation, statistical analysis, and robustness testing. The field has developed standardized methodological approaches -- earnings quality models, event studies, difference-in-differences for regulatory changes, and instrument variable strategies for endogeneity -- that are implemented in a relatively stable set of STATA patterns.
This guide provides the core STATA code patterns used in top accounting journals (The Accounting Review, Journal of Accounting Research, Journal of Accounting and Economics, and Review of Accounting Studies). These patterns are drawn from commonly used research designs in financial reporting, auditing, tax, and managerial accounting research.
Whether you are estimating discretionary accruals, conducting an event study around an earnings announcement, testing the effect of auditor rotation on audit quality, or implementing a regulatory shock analysis, these patterns provide tested, reviewable STATA implementations.
* ============================================================
* COMPUSTAT Annual Data Preparation for Accounting Research
* Standard preparation used across most empirical accounting papers
* ============================================================
* Load COMPUSTAT annual data
use "compustat_annual.dta", clear
* Keep relevant variables
keep gvkey fyear datadate at sale cogs xsga dp ib oancf act lct che dlc ///
csho prcc_f ceq re dltt txp xrd ppegt ppent invt rect
* Set panel structure
destring gvkey, replace
xtset gvkey fyear
* --- Basic cleaning ---
* Drop financial firms (SIC 6000-6999) and utilities (SIC 4900-4999)
drop if inrange(sic, 6000, 6999) | inrange(sic, 4900, 4999)
* Require minimum observations
bysort gvkey: gen nobs = _N
drop if nobs < 3
drop nobs
test cases passed, vs 8 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.