stata
Skill1 starsChanged 7 months agoMITView on GitHub
Execute Stata .do files on a remote Windows machine via the stata-bridge (SSHFS + file queue). Use whenever the user wants to run Stata code, debug a .do file, run a regression, clean data in Stata, check Stata job status, or tail a Stata log. Also triggers when user mentions Stata commands (regress, reghdfe, xtreg, etc.) or opens a .do file in /stata/workspace/.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- Ricardo-kui/claude-skillstheir own version, first seen Sep 10, 2026
- snitkin/claude-skillstheir own version, first seen Jul 8, 2026
- luischanci/claude-code-research-startertheir own version, first seen Feb 13, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- luischanci/claude-code-research-starter★ 1same name
- Ricardo-kui/claude-skills★ 0same name
- snitkin/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Files
Stata Skill
跑 Stata 的唯一通道。本服务器没装 Stata,必须通过 /stata/bin/stata-* 把 .do 派发到用户 Windows 机器执行。
详细上下文已在
/stata/CLAUDE.md预加载,本文件是/stata调用时的速查。
双目录约定(必读)
| 宏 | 放什么 | 服务器可见? |
$WORK(= /stata/workspace/) | .do / 日志 / 小结果 | ✅ |
$DATA(Windows 本地盘) | 原始 .dta | ❌ |
写 .do 时永远用宏:
use "$DATA/big.dta", clear
use "$DATA/project-a/wave1.dta", clear // 子目录 OK
use "$DATA/hudonge and analyst/coverage.dta", clear // 空格 / 中文 OK,记得加引号
save "$WORK/output/cleaned.dta", replace
log using "$WORK/logs/run.log", replace
* 读进来第一件事:把中文变量名重命名为 ascii(避免 length() 卡死,见"禁止"节 B1)
rename 股票代码 stkcode
rename year yr列 $DATA 下有哪些数据(batch 安全,不用 shell):
local subs : dir "$DATA" dirs "*"
foreach s of local subs {
local fs : dir "$DATA/`s'" files "*.dta"
foreach f of local fs display "`s'/`f'"
}一分钟速用
# 1. 先 ping,确认 Windows agent 活着
/stata/bin/stata-ping
# 2. 写 .do 到 workspace/(不要加 set processors,profile.do 已自动)
cat > /stata/workspace/my.do <<'EOF'
use "$DATA/data.dta", clear
reg y x1 x2
EOF
# 3. 同步执行(迭代首选)
/stata/bin/stata-run workspace/my.do --tail 80
# 4. 长作业改异步
JOB=$(/stata/bin/stata-async workspace/big.do --timeout 14400)
/stata/bin/stata-log $JOB --follow调试循环
Read当前 .doEdit改动stata-run file.do --tail 60- 看 log 尾部找
r(XXX);错误行 - GOTO 2
我要"看看数据长啥样"怎么办
服务器读不到 .dta 原文。写一个探查 .do,让 Stata 把元信息写到 $WORK/logs/ 下,我再 Read 文本:
log using "$WORK/logs/_describe.log", text replace
use "$DATA/target.dta", clear
describe
codebook, compact
summarize
list in 1/20
log closeExit code
| code | 含义 | 行动 |
| 0 | 成功 | ✅ |
| 4 | agent 失联 | 提醒用户查 Scheduled Task |
| 5 | 超时 | 用 stata-status 继续观察 |
| 10 | Stata r(...) 错误 | 读 log 定位错误行 |
| 11 | Windows 进程非 0 | 看 log + agent 日志 |
| 12 | result.json 解析失败 | 罕见,重试 |
禁止
- ❌
bash -c "stata ..."— 服务器没装 Stata - ❌
use "workspace/foo.dta"或 Windows 绝对路径 — 用$DATA/$WORK - ❌ 建议用户把
.dta放workspace/—— 几百 MB 走 SSHFS 会很慢 - ❌ 在 .do 里加
set processors N—profile.do已接管 - ❌ 直接动
.bridge/running/文件 - ❌ 对中文变量名调
length()/strlen()— 本仓库实测会静默卡死(Stata 17 MP,batch 模式下无r(...)、agent 汇报has_stata_error=false、timed_out=false、exit_code=null,但 log 从该命令后再无输出)。第一步先rename 股票代码 stkcode成 ascii,之后再用任何字符串函数
常见错误码
r(XXX); | 含义 |
| 111 | variable not found |
| 198 | syntax error |
| 601 | file not found(常因 $DATA 未配置,检查 workspace/bridge.config.do) |
| 2000 | no observations |
| 430 | convergence not achieved |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

