Stata Skill
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.
Critical Gotchas
These are Stata-specific pitfalls that lead to silent bugs. Internalize these before writing any code.
Missing Values Sort to +Infinity
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)
= vs ==
= 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
Local Macro Syntax
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
by Requires Prior Sort (Use bysort)
* 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)
Factor Variable Notation (i. and c.)
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 vs replace
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
String Comparison Is Case-Sensitive
* May miss "Male", "MALE", etc.
keep if gender == "male"
* Safer
keep if lower(gender) == "male"
merge Always Check _merge
merge 1:1 id using other.dta
tab _merge // always inspect
assert _merge == 3 // or handle mismatches
drop _merge
preserve / restore for Temporary Changes
preserve
collapse (mean) income, by(state)
* ... do something with collapsed data ...
restore // original data is back
Weights Are Not Interchangeable
fweight — frequency weights (replication)
aweight — analytic/regression weights (inverse variance)
pweight — probability/sampling weights (survey data, implies robust SE)
iweight — importance weights (rarely used)
capture Swallows Errors
capture some_command
if _rc != 0 {
di as error "Failed with code: " _rc
exit _rc
}
Line Continuation Uses ///
regress y x1 x2 x3 ///
x4 x5 x6, ///
vce(robust)
Stored Results: r() vs e() vs s()
r() — r-class commands (summarize, tabulate, etc.)
e() — e-class commands (estimation: regress, logit, etc.)
s() — s-class commands (parsing)
A new estimation command overwrites previous e() results. Store them first:
regress y x1 x2
estimates store model1
Routing Table
Read only the files relevant to the user's task. Paths are relative to this SKILL.md file.
Data Operations
| File |
Topics & Key Commands |
references/basics-getting-started.md |
use, save, describe, browse, sysuse, basic workflow |
references/data-import-export.md |
import delimited, import excel, ODBC, export, web data |
references/data-management.md |
generate, replace, merge, append, reshape, collapse, recode, egen, encode/decode |
references/variables-operators.md |
Variable types, byte/int/long/float/double, operators, missing values (.<.a), if/in qualifiers |
references/string-functions.md |
substr(), regexm(), strtrim(), split, ustrlen(), regex, Unicode |
references/date-time-functions.md |
date(), clock(), %td/%tc formats, mdy(), dofm(), business calendars |
references/mathematical-functions.md |
round(), log(), exp(), abs(), mod(), cond(), distributions, random numbers |
Statistics & Econometrics
| File |
Topics & Key Commands |
references/descriptive-statistics.md |
summarize, tabulate, correlate, tabstat, codebook, weighted stats |
references/linear-regression.md |
regress, vce(robust), vce(cluster), test, lincom, margins, predict, ivregress |
references/panel-data.md |
xtset, xtreg fe/re, Hausman test, xtabond, dynamic panels |
references/time-series.md |
tsset, ARIMA, VAR, dfuller, pperron, irf, forecasting |
references/limited-dependent-variables.md |
logit, probit, tobit, poisson, nbreg, mlogit, ologit, margins for nonlinear |
references/bootstrap-simulation.md |
bootstrap, simulate, permute, Monte Carlo |
references/survey-data-analysis.md |
svyset, svy:, subpop(), complex survey design, replicate weights |
references/missing-data-handling.md |
mi impute, mi estimate, FIML, misstable, diagnostics |
references/maximum-likelihood.md |
ml model, custom likelihood functions, ml init, gradient-based optimization |
references/gmm-estimation.md |
gmm, moment conditions, estat overid, J-test |
Causal Inference
| File |
Topics & Key Commands |
references/treatment-effects.md |
teffects ra/ipw/ipwra/aipw, stteffects, ATE/ATT/ATET |
references/difference-in-differences.md |
DiD, parallel trends, event studies, staggered adoption |
references/regression-discontinuity.md |
Sharp/fuzzy RD, bandwidth selection, rdplot |
references/matching-methods.md |
PSM, nearest neighbor, kernel matching, teffects nnmatch |
references/sample-selection.md |
heckman, heckprobit, treatment models, exclusion restrictions |
Advanced Methods
| File |
Topics & Key Commands |
references/survival-analysis.md |
stset, stcox, streg, Kaplan-Meier, parametric models |
references/sem-factor-analysis.md |
sem, gsem, CFA, path analysis, alpha, reliability |
references/nonparametric-methods.md |
kdensity, rank tests, qreg, npregress |
references/spatial-analysis.md |
spmatrix, spregress, spatial weights, Moran's I |
references/machine-learning.md |
lasso, elasticnet, cvlasso, cross-validation |
Graphics
| File |
Topics & Key Commands |
references/graphics.md |
twoway, scatter, line, bar, histogram, graph combine, graph export, schemes |
Programming
| File |
Topics & Key Commands |
references/programming-basics.md |
local, global, foreach, forvalues, program define, syntax, return |
references/advanced-programming.md |
syntax, mata, classes, _prefix, dialog boxes, tempfile/tempvar |
references/mata-introduction.md |
Mata basics, when to use Mata vs ado, data types |
references/mata-programming.md |
Mata functions, flow control, structures, pointers |
references/mata-matrix-operations.md |
Matrix creation, decompositions, solvers, st_matrix() |
references/mata-data-access.md |
st_data(), st_view(), st_store(), performance tips |
Output & Workflow
| File |
Topics & Key Commands |
references/tables-reporting.md |
putexcel, putdocx, putpdf, LaTeX integration, collect |
references/workflow-best-practices.md |
Project structure, master do-files, version control, debugging, common mistakes |
references/external-tools-integration.md |
Python via python:, R via rsource, shell commands, Git |
Community Packages
| File |
What It Does |
packages/reghdfe.md |
High-dimensional fixed effects OLS (absorbs multiple FE sets efficiently) |
packages/estout.md |
esttab/estout: publication-quality regression tables |
packages/outreg2.md |
Alternative regression table exporter (Word, Excel, TeX) |
packages/asdoc.md |
One-command Word document creation for any Stata output |
packages/tabout.md |
Cross-tabulations and summary tables to file |
packages/coefplot.md |
Coefficient plots from stored estimates |
packages/graph-schemes.md |
grstyle, schemepack, plotplain — better graph themes |
packages/did.md |
Modern DiD: csdid, did_multiplegt, did_imputation (Callaway-Sant'Anna, de Chaisemartin-D'Haultfoeuille, Borusyak-Jaravel-Spiess) |
packages/event-study.md |
eventstudyinteract, eventdd — event study estimators |
packages/rdrobust.md |
Robust RD estimation with optimal bandwidth (rdrobust, rdplot, rdbwselect) |
packages/psmatch2.md |
Propensity score matching (nearest neighbor, kernel, radius) |
packages/synth.md |
Synthetic control method (synth, synth_runner) |
packages/ivreg2.md |
Enhanced IV/2SLS: ivreg2, xtivreg2 with additional diagnostics |
packages/xtabond2.md |
Dynamic panel GMM (Arellano-Bond/Blundell-Bond) |
packages/binsreg.md |
Binned scatter plots with CI (binsreg, binstest) |
packages/nprobust.md |
Nonparametric kernel estimation and inference |
packages/diagnostics.md |
bacondecomp, xttest3, collinearity, heteroskedasticity tests |
packages/winsor.md |
Winsorizing and trimming: winsor2, winsor |
packages/data-manipulation.md |
gtools (fast collapse/egen), rangestat, egenmore |
packages/package-management.md |
ssc install, net install, ado update, finding packages |
Common Patterns
Regression Table Workflow
* Estimate models
eststo clear
eststo: regress y x1 x2, vce(robust)
eststo: regress y x1 x2 x3, vce(robust)
eststo: regress y x1 x2 x3 x4, vce(cluster id)
* Export table
esttab using "results.tex", replace ///
se star(* 0.10 ** 0.05 *** 0.01) ///
label booktabs ///
title("Main Results") ///
mtitles("(1)" "(2)" "(3)")
Panel Data Setup
xtset panelid timevar // declare panel structure
xtdescribe // check balance
xtsum outcome // within/between variation
* Fixed effects
xtreg y x1 x2, fe vce(cluster panelid)
* Or with reghdfe (preferred for multiple FE)
reghdfe y x1 x2, absorb(panelid timevar) vce(cluster panelid)
Difference-in-Differences
* Classic 2x2 DiD
gen post = (year >= treatment_year)
gen treat_post = treated * post
regress y treated post treat_post, vce(cluster id)
* Modern staggered DiD (Callaway & Sant'Anna)
csdid y x1 x2, ivar(id) time(year) gvar(first_treat) agg(event)
csdid_plot
Graph Export
* Publication-quality scatter with fit line
twoway (scatter y x, mcolor(navy%50) msize(small)) ///
(lfit y x, lcolor(cranberry) lwidth(medthick)), ///
title("Title Here") ///
xtitle("X Label") ytitle("Y Label") ///
legend(off) scheme(s2color)
graph export "figure1.pdf", replace as(pdf)
graph export "figure1.png", replace as(png) width(2400)
Data Cleaning Pipeline
* Load and inspect
import delimited "raw_data.csv", clear varnames(1)
describe
codebook, compact
* Clean
rename *, lower // lowercase all varnames
destring income, replace force // convert string to numeric
replace income = . if income < 0
* Label
label variable income "Annual household income (USD)"
label define yesno 0 "No" 1 "Yes"
label values employed yesno
* Save
compress
save "clean_data.dta", replace
Multiple Imputation
mi set mlong
mi register imputed income education
mi impute chained (regress) income (ologit) education = age i.gender, add(20) rseed(12345)
mi estimate: regress wage income education age i.gender
1---2name: stata-33description: Comprehensive Stata reference for writing correct .do files, data management, econometrics, causal inference, graphics, Mata programming, and 17+ 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.4---5
6# Stata Skill
7
8You have access to comprehensive Stata reference files. **Do not load all files.**
9Read only the 1-3 files relevant to the user's current task using the routing table below.
10
11---
12
13## Critical Gotchas
14
15These are Stata-specific pitfalls that lead to silent bugs. Internalize these before writing any code.
16
17### Missing Values Sort to +Infinity
18Stata's `.` (and `.a`-`.z`) are **greater than all numbers**.
19```stata
20* WRONG — includes observations where income is missing!
21gen high_income = (income > 50000)
22
23* RIGHT
24gen high_income = (income > 50000) if !missing(income)
25
26* WRONG — missing ages appear in this list
27list if age > 60
28
29* RIGHT
30list if age > 60 & !missing(age)
31```
32
33### `=` vs `==`
34`=` is assignment; `==` is comparison. Mixing them up is a syntax error or silent bug.
35```stata
36* WRONG — syntax error
37gen employed = 1 if status = 1
38
39* RIGHT
40gen employed = 1 if status == 1
41```
42
43### Local Macro Syntax
44Locals use `` `name' `` (backtick + single-quote). Globals use `$name` or `${name}`.
45Forgetting the closing quote is the #1 macro bug.
46```stata
47local controls "age education income"
48regress wage `controls' // correct
49regress wage `controls // WRONG — missing closing quote
50regress wage 'controls' // WRONG — wrong quote characters
51```
52
53### `by` Requires Prior Sort (Use `bysort`)
54```stata
55* WRONG — error if data not sorted by id
56by id: gen first = (_n == 1)
57
58* RIGHT — bysort sorts automatically
59bysort id: gen first = (_n == 1)
60
61* Also RIGHT — explicit sort
62sort id
63by id: gen first = (_n == 1)
64```
65
66### Factor Variable Notation (`i.` and `c.`)
67Use `i.` for categorical, `c.` for continuous. Omitting `i.` treats categories as continuous.
68```stata
69* WRONG — treats race as continuous (e.g., race=3 has 3x effect of race=1)
70regress wage race education
71
72* RIGHT — creates dummies automatically
73regress wage i.race education
74
75* Interactions
76regress wage i.race##c.education // full interaction
77regress wage i.race#c.education // interaction only (no main effects)
78```
79
80### `generate` vs `replace`
81`generate` creates new variables; `replace` modifies existing ones. Using `generate` on an existing variable name is an error.
82```stata
83gen x = 1
84gen x = 2 // ERROR: x already defined
85replace x = 2 // correct
86```
87
88### String Comparison Is Case-Sensitive
89```stata
90* May miss "Male", "MALE", etc.
91keep if gender == "male"
92
93* Safer
94keep if lower(gender) == "male"
95```
96
97### `merge` Always Check `_merge`
98```stata
99merge 1:1 id using other.dta
100tab _merge // always inspect
101assert _merge == 3 // or handle mismatches
102drop _merge
103```
104
105### `preserve` / `restore` for Temporary Changes
106```stata
107preserve
108collapse (mean) income, by(state)
109* ... do something with collapsed data ...
110restore // original data is back
111```
112
113### Weights Are Not Interchangeable
114- `fweight` — frequency weights (replication)
115- `aweight` — analytic/regression weights (inverse variance)
116- `pweight` — probability/sampling weights (survey data, implies robust SE)
117- `iweight` — importance weights (rarely used)
118
119### `capture` Swallows Errors
120```stata
121capture some_command
122if _rc != 0 {
123 di as error "Failed with code: " _rc
124 exit _rc
125}
126```
127
128### Line Continuation Uses `///`
129```stata
130regress y x1 x2 x3 ///
131 x4 x5 x6, ///
132 vce(robust)
133```
134
135### Stored Results: `r()` vs `e()` vs `s()`
136- `r()` — r-class commands (summarize, tabulate, etc.)
137- `e()` — e-class commands (estimation: regress, logit, etc.)
138- `s()` — s-class commands (parsing)
139
140A new estimation command **overwrites** previous `e()` results. Store them first:
141```stata
142regress y x1 x2
143estimates store model1
144```
145
146---
147
148## Routing Table
149
150Read only the files relevant to the user's task. Paths are relative to this SKILL.md file.
151
152### Data Operations
153| File | Topics & Key Commands |
154|------|----------------------|
155| `references/basics-getting-started.md` | `use`, `save`, `describe`, `browse`, `sysuse`, basic workflow |
156| `references/data-import-export.md` | `import delimited`, `import excel`, ODBC, `export`, web data |
157| `references/data-management.md` | `generate`, `replace`, `merge`, `append`, `reshape`, `collapse`, `recode`, `egen`, `encode`/`decode` |
158| `references/variables-operators.md` | Variable types, `byte`/`int`/`long`/`float`/`double`, operators, missing values (`.<.a`), `if`/`in` qualifiers |
159| `references/string-functions.md` | `substr()`, `regexm()`, `strtrim()`, `split`, `ustrlen()`, regex, Unicode |
160| `references/date-time-functions.md` | `date()`, `clock()`, `%td`/`%tc` formats, `mdy()`, `dofm()`, business calendars |
161| `references/mathematical-functions.md` | `round()`, `log()`, `exp()`, `abs()`, `mod()`, `cond()`, distributions, random numbers |
162
163### Statistics & Econometrics
164| File | Topics & Key Commands |
165|------|----------------------|
166| `references/descriptive-statistics.md` | `summarize`, `tabulate`, `correlate`, `tabstat`, `codebook`, weighted stats |
167| `references/linear-regression.md` | `regress`, `vce(robust)`, `vce(cluster)`, `test`, `lincom`, `margins`, `predict`, `ivregress` |
168| `references/panel-data.md` | `xtset`, `xtreg fe`/`re`, Hausman test, `xtabond`, dynamic panels |
169| `references/time-series.md` | `tsset`, ARIMA, VAR, `dfuller`, `pperron`, `irf`, forecasting |
170| `references/limited-dependent-variables.md` | `logit`, `probit`, `tobit`, `poisson`, `nbreg`, `mlogit`, `ologit`, `margins` for nonlinear |
171| `references/bootstrap-simulation.md` | `bootstrap`, `simulate`, `permute`, Monte Carlo |
172| `references/survey-data-analysis.md` | `svyset`, `svy:`, `subpop()`, complex survey design, replicate weights |
173| `references/missing-data-handling.md` | `mi impute`, `mi estimate`, FIML, `misstable`, diagnostics |
174| `references/maximum-likelihood.md` | `ml model`, custom likelihood functions, `ml init`, gradient-based optimization |
175| `references/gmm-estimation.md` | `gmm`, moment conditions, `estat overid`, J-test |
176
177### Causal Inference
178| File | Topics & Key Commands |
179|------|----------------------|
180| `references/treatment-effects.md` | `teffects ra/ipw/ipwra/aipw`, `stteffects`, ATE/ATT/ATET |
181| `references/difference-in-differences.md` | DiD, parallel trends, event studies, staggered adoption |
182| `references/regression-discontinuity.md` | Sharp/fuzzy RD, bandwidth selection, `rdplot` |
183| `references/matching-methods.md` | PSM, nearest neighbor, kernel matching, `teffects nnmatch` |
184| `references/sample-selection.md` | `heckman`, `heckprobit`, treatment models, exclusion restrictions |
185
186### Advanced Methods
187| File | Topics & Key Commands |
188|------|----------------------|
189| `references/survival-analysis.md` | `stset`, `stcox`, `streg`, Kaplan-Meier, parametric models |
190| `references/sem-factor-analysis.md` | `sem`, `gsem`, CFA, path analysis, `alpha`, reliability |
191| `references/nonparametric-methods.md` | `kdensity`, rank tests, `qreg`, `npregress` |
192| `references/spatial-analysis.md` | `spmatrix`, `spregress`, spatial weights, Moran's I |
193| `references/machine-learning.md` | `lasso`, `elasticnet`, `cvlasso`, cross-validation |
194
195### Graphics
196| File | Topics & Key Commands |
197|------|----------------------|
198| `references/graphics.md` | `twoway`, `scatter`, `line`, `bar`, `histogram`, `graph combine`, `graph export`, schemes |
199
200### Programming
201| File | Topics & Key Commands |
202|------|----------------------|
203| `references/programming-basics.md` | `local`, `global`, `foreach`, `forvalues`, `program define`, `syntax`, `return` |
204| `references/advanced-programming.md` | `syntax`, `mata`, classes, `_prefix`, dialog boxes, `tempfile`/`tempvar` |
205| `references/mata-introduction.md` | Mata basics, when to use Mata vs ado, data types |
206| `references/mata-programming.md` | Mata functions, flow control, structures, pointers |
207| `references/mata-matrix-operations.md` | Matrix creation, decompositions, solvers, `st_matrix()` |
208| `references/mata-data-access.md` | `st_data()`, `st_view()`, `st_store()`, performance tips |
209
210### Output & Workflow
211| File | Topics & Key Commands |
212|------|----------------------|
213| `references/tables-reporting.md` | `putexcel`, `putdocx`, `putpdf`, LaTeX integration, `collect` |
214| `references/workflow-best-practices.md` | Project structure, master do-files, version control, debugging, common mistakes |
215| `references/external-tools-integration.md` | Python via `python:`, R via `rsource`, shell commands, Git |
216
217### Community Packages
218| File | What It Does |
219|------|-------------|
220| `packages/reghdfe.md` | High-dimensional fixed effects OLS (absorbs multiple FE sets efficiently) |
221| `packages/estout.md` | `esttab`/`estout`: publication-quality regression tables |
222| `packages/outreg2.md` | Alternative regression table exporter (Word, Excel, TeX) |
223| `packages/asdoc.md` | One-command Word document creation for any Stata output |
224| `packages/tabout.md` | Cross-tabulations and summary tables to file |
225| `packages/coefplot.md` | Coefficient plots from stored estimates |
226| `packages/graph-schemes.md` | `grstyle`, `schemepack`, `plotplain` — better graph themes |
227| `packages/did.md` | Modern DiD: `csdid`, `did_multiplegt`, `did_imputation` (Callaway-Sant'Anna, de Chaisemartin-D'Haultfoeuille, Borusyak-Jaravel-Spiess) |
228| `packages/event-study.md` | `eventstudyinteract`, `eventdd` — event study estimators |
229| `packages/rdrobust.md` | Robust RD estimation with optimal bandwidth (`rdrobust`, `rdplot`, `rdbwselect`) |
230| `packages/psmatch2.md` | Propensity score matching (nearest neighbor, kernel, radius) |
231| `packages/synth.md` | Synthetic control method (`synth`, `synth_runner`) |
232| `packages/ivreg2.md` | Enhanced IV/2SLS: `ivreg2`, `xtivreg2` with additional diagnostics |
233| `packages/xtabond2.md` | Dynamic panel GMM (Arellano-Bond/Blundell-Bond) |
234| `packages/binsreg.md` | Binned scatter plots with CI (`binsreg`, `binstest`) |
235| `packages/nprobust.md` | Nonparametric kernel estimation and inference |
236| `packages/diagnostics.md` | `bacondecomp`, `xttest3`, collinearity, heteroskedasticity tests |
237| `packages/winsor.md` | Winsorizing and trimming: `winsor2`, `winsor` |
238| `packages/data-manipulation.md` | `gtools` (fast collapse/egen), `rangestat`, `egenmore` |
239| `packages/package-management.md` | `ssc install`, `net install`, `ado update`, finding packages |
240
241---
242
243## Common Patterns
244
245### Regression Table Workflow
246```stata
247* Estimate models
248eststo clear
249eststo: regress y x1 x2, vce(robust)
250eststo: regress y x1 x2 x3, vce(robust)
251eststo: regress y x1 x2 x3 x4, vce(cluster id)
252
253* Export table
254esttab using "results.tex", replace ///
255 se star(* 0.10 ** 0.05 *** 0.01) ///
256 label booktabs ///
257 title("Main Results") ///
258 mtitles("(1)" "(2)" "(3)")
259```
260
261### Panel Data Setup
262```stata
263xtset panelid timevar // declare panel structure
264xtdescribe // check balance
265xtsum outcome // within/between variation
266
267* Fixed effects
268xtreg y x1 x2, fe vce(cluster panelid)
269* Or with reghdfe (preferred for multiple FE)
270reghdfe y x1 x2, absorb(panelid timevar) vce(cluster panelid)
271```
272
273### Difference-in-Differences
274```stata
275* Classic 2x2 DiD
276gen post = (year >= treatment_year)
277gen treat_post = treated * post
278regress y treated post treat_post, vce(cluster id)
279
280* Modern staggered DiD (Callaway & Sant'Anna)
281csdid y x1 x2, ivar(id) time(year) gvar(first_treat) agg(event)
282csdid_plot
283```
284
285### Graph Export
286```stata
287* Publication-quality scatter with fit line
288twoway (scatter y x, mcolor(navy%50) msize(small)) ///
289 (lfit y x, lcolor(cranberry) lwidth(medthick)), ///
290 title("Title Here") ///
291 xtitle("X Label") ytitle("Y Label") ///
292 legend(off) scheme(s2color)
293graph export "figure1.pdf", replace as(pdf)
294graph export "figure1.png", replace as(png) width(2400)
295```
296
297### Data Cleaning Pipeline
298```stata
299* Load and inspect
300import delimited "raw_data.csv", clear varnames(1)
301describe
302codebook, compact
303
304* Clean
305rename *, lower // lowercase all varnames
306destring income, replace force // convert string to numeric
307replace income = . if income < 0
308
309* Label
310label variable income "Annual household income (USD)"
311label define yesno 0 "No" 1 "Yes"
312label values employed yesno
313
314* Save
315compress
316save "clean_data.dta", replace
317```
318
319### Multiple Imputation
320```stata
321mi set mlong
322mi register imputed income education
323mi impute chained (regress) income (ologit) education = age i.gender, add(20) rseed(12345)
324mi estimate: regress wage income education age i.gender
325```