pipeline
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy + statsmodels + linearmodels + pyfixest +…
Comprehensive Stata reference for writing correct .do files, data management, econometrics, causal inference, graphics, Mata programming, and 20 community packages (reghdfe, estout, did, rdrobust, etc.). Covers syntax, options, gotchas, and idiomatic patterns. Use this skill
$ npx -y skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill stata --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/stataContext preview
The summary Claude sees to decide when to auto-load this skill.
Comprehensive Stata reference for writing correct .do files, data management, econometrics, causal inference, graphics, Mata programming, and 20 community packages (reghdfe, estout, did, rdrobust, etc.). Covers syntax, options, gotchas, and idiomatic patterns. Use this skill
name: stata description: > Comprehensive Stata reference for writing correct .do files, data management, econometrics, causal inference, graphics, Mata programming, and 20 community packages (reghdfe, estout, did, rdrobust, etc.). Covers syntax, options, gotchas, and idiomatic patterns. Use this skill whenever the user asks you to write, debug, or explain Stata code.
You have access to comprehensive Stata reference files. **Do not load all files.** Read only the 1-3 files relevant to the user's current task using the routing table below.
---
These are Stata-specific pitfalls that lead to silent bugs. Internalize these before writing any code.
Stata's `.` (and `.a`-`.z`) are **greater than all numbers**.
* WRONG — includes observations where income is missing! gen high_income = (income > 50000) * RIGHT gen high_income = (income > 50000) if !missing(income) * WRONG — missing ages appear in this list list if age > 60 * RIGHT list if age > 60 & !missing(age)
`=` is assignment; `==` is comparison. Mixing them up is a syntax error or silent bug.
* WRONG — syntax error gen employed = 1 if status = 1 * RIGHT gen employed = 1 if status == 1
Locals use `` `name' `` (backtick + single-quote). Globals use `$name` or `${name}`. Forgetting the closing quote is the #1 macro bug.
local controls "age education income" regress wage `controls' // correct regress wage `controls // WRONG — missing closing quote regress wage 'controls' // WRONG — wrong quote characters
* WRONG — error if data not sorted by id by id: gen first = (_n == 1) * RIGHT — bysort sorts automatically bysort id: gen first = (_n == 1) * Also RIGHT — explicit sort sort id by id: gen first = (_n == 1)
Use `i.` for categorical, `c.` for continuous. Omitting `i.` treats categories as continuous.
* WRONG — treats race as continuous (e.g., race=3 has 3x effect of race=1) regress wage race education * RIGHT — creates dummies automatically regress wage i.race education * Interactions regress wage i.race##c.education // full interaction regress wage i.race#c.education // interaction only (no main effects)
`generate` creates new variables; `replace` modifies existing ones. Using `generate` on an existing variable name is an error.
gen x = 1 gen x = 2 // ERROR: x already defined replace x = 2 // correct
* May miss "Male", "MALE", etc. keep if gender == "male" * Safer keep if lower(gender) == "male"
Never skip `tab _merge` — it costs nothing and is the only diagnostic you get when `assert` fails.
merge 1:1 id using other.dta tab _merge // ALWAYS tab before assert assert _merge == 3 // fails silently without tab output drop _merge
The standard pattern for computing group stats and merging them onto the original data:
tempfile stats preserve collapse (mean) avg_x=x, by(group) save `stats' restore merge m:1 group using `stats' tab _merge assert _merge == 3 drop _merge
For simple group means, `bysort group: egen avg_x = mean(x)` avoids the round-trip entirely.
capture some_command
if _rc != 0 {
di as error "Failed with code: " _rc
exit _rc
}regress y x1 x2 x3 ///
x4 x5 x6, ///
vce(robust)A new estimation command **overwrites** previous `e()` results. Store them first:
regress y x1 x2 estimates store model1
---
Claude can execute Stata code by running `.do` files in batch mode from the terminal. This is how to run Stata non-interactively.
Stata on macOS is a `.app` bundle. The actual binary is inside it. Common locations:
# Stata 18 / StataNow (most common) /Applications/Stata/StataMP.app/Contents/MacOS/stata-mp /Applications/StataNow/StataMP.app/Contents/MacOS/stata-mp # Other editions (SE, BE) /Applications/Stata/StataSE.app/Contents/MacOS/stata-se /Applications/Stata/StataBE.app/Contents/MacOS/stata-be
If Stata isn't on `$PATH`, find it with: `mdfind -name "stata-mp" | grep MacOS`
# Run a .do file in batch mode — output goes to <filename>.log /Applications/Stata/StataMP.app/Contents/MacOS/stata-mp -b do analysis.do # If stata-mp is on PATH (e.g., via symlink or alias): stata-mp -b do analysis.do
To run a quick Stata snippet without creating a `.do` file:
# Write a temp .do file and run it cat > /tmp/stata_run.do << 'EOF' sysuse auto, clear summarize price mpg EOF stata-mp -b do /tmp/stata_run.do cat /tmp/stata_run.log
# Check if it succeeded stata-mp -b do tests/run_tests.do && echo "SUCCESS" || echo "FAILED" # Search
📌 文档结构(2026-07-22 起): 本文件是中文默认入口 —— banner + badges + 信任面 + 9 阶段流水线速览 + 76 行合集总表。 每个合集的完整描述、按用途分组、精确数字、验证方法在 docs/CONTENT_ZH.md(扩展正文,总表行内的 → 直接跳转到对应锚点)。 English version: README-en.md · 中文扩展正文:docs/CONTENT_ZH.md · README-zh-CN.md 已弃用(重定向占位) 🌐 语言: English |
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy + statsmodels + linearmodels + pyfixest +…
Use when the user asks to run a full empirical / causal analysis in Python — by default in the style of an applied economics paper (AER / QJE / JPE / ReStud /…
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy + statsmodels + linearmodels + pyfixest +…
Classical end-to-end empirical analysis workflow in the traditional Stata ecosystem — native Stata + reghdfe + ivreg2 + csdid + did_imputation +…
Classical end-to-end empirical analysis workflow in the modern tidyverse + econometrics R ecosystem — dplyr + tidyr + haven + fixest + sandwich + lmtest +…
Systematic writing framework for philosophy and interdisciplinary academic papers from optimized outline to submission-ready manuscript. Use when users want…