Stata Pre-flight
Before running or finishing edits to any .do file, run these checks. The user's Stata username is <your-stata-username> (Stata base path /Users/<your-username>/).
1. Username path branch
Every do-file needs a <your-stata-username> branch in its path-setting block:
grep -L "<your-stata-username>" path/to/file.do
If the file is listed (no match), the path block is missing the user's branch and the script will fail silently on this machine. Add a branch like:
if "`c(username)'" == "<your-stata-username>" {
global root "/Users/<your-username>/.../<project>"
}
2. No cap around esttab
grep -nE "(^|[^a-z])cap(ture)?[[:space:]]+esttab" path/to/file.do
Any hit must be unwrapped. cap esttab silently drops in-memory estimates, producing empty tables. Same goes for cap est store chains that feed esttab.
3. Log file declared
Confirm the do-file opens a log:
grep -nE "^log using" path/to/file.do
If missing, add one near the top so failures leave a diagnosable trail.
4. After running
- Verify
*.logwas produced and mtime is recent. - Open the tail of the log and confirm no
r(xxx);errors before declaring success. - If using
esttab, confirm the output.tex/.csvwas actually written and has content.
Reporting
Report each check as PASS/FAIL. If anything is FAIL, do not run the script — fix first.