Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问许可证需确认审计通过

statastata 搜索

Agent Skill

stata 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,697

周安装

68

GitHub Stars

188

下载量

549
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:stata(stata 搜索)
来源仓库:https://github.com/dylantmoore/stata-skill
仓库路径:skills/stata
安装命令:
npx skills add https://github.com/dylantmoore/stata-skill --skill stata
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dylantmoore/stata-skill --skill stata

简介

stata 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 适用于需要根据关键词或任务场景进行信息检索的场景,如统计分析、数据处理。
  • 通过 npx skills add 命令从 GitHub 仓库安装,需结合原始 README 确认具体用法。
  • 安装前建议确认权限范围和维护状态,注意是否会触发联网或文件读写操作。
  • 建议核验来源仓库内容,确保功能与预期一致后再投入实际使用。

SKILL.md

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

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

preserve / restore + tempfile for Collapse-Merge-Back

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.

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

Running Stata from the Command Line

Claude can execute Stata code by running .do files in batch mode from the terminal. This is how to run Stata non-interactively.

Finding the Stata Binary

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

Batch Mode (-b)

# 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
  • -b = batch mode (non-interactive, no GUI)
  • Output (everything Stata would display) is written to analysis.log in the working directory
  • Exit code is 0 on success, non-zero on error
  • The log file contains all output, including error messages — check it after execution

Running Inline Stata Code

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

Checking Results

# Check if it succeeded
stata-mp -b do tests/run_tests.do && echo "SUCCESS" || echo "FAILED"

# Search the log for pass/fail
grep -E "PASS|FAIL|error|r\([0-9]+\)" run_tests.log

Tips

  • clear all at the top of batch scripts — batch mode starts with a fresh Stata session, but clear all ensures no stale state from prior runs in the same session.
  • set more off — prevents Stata from pausing for --more-- prompts (fatal in batch mode).
  • Log files overwrite silentlyanalysis.do always writes to analysis.log in the current directory. If you run multiple .do files, check the right log.
  • Working directory — Stata's working directory is wherever you run the command from, not where the .do file lives. Use cd in the .do file or absolute paths if needed.

Routing Table

Read only the files relevant to the user's task. Paths are relative to this SKILL.md file.

Data Operations

FileTopics & Key Commands
references/basics-getting-started.mduse, save, describe, browse, sysuse, basic workflow
references/data-import-export.mdimport delimited, import excel, ODBC, export, web data
references/data-management.mdgenerate, replace, merge, append, reshape, collapse, recode, egen, encode/decode
references/variables-operators.mdVariable types, byte/int/long/float/double, operators, missing values (.<.a), if/in qualifiers
references/string-functions.mdsubstr(), regexm(), strtrim(), split, ustrlen(), regex, Unicode
references/date-time-functions.mddate(), clock(), %td/%tc formats, mdy(), dofm(), business calendars
references/mathematical-functions.mdround(), log(), exp(), abs(), mod(), cond(), distributions, random numbers

Statistics & Econometrics

FileTopics & Key Commands
references/descriptive-statistics.mdsummarize, tabulate, correlate, tabstat, codebook, weighted stats
references/linear-regression.mdregress, vce(robust), vce(cluster), test, lincom, margins, predict, ivregress
references/panel-data.mdxtset, xtreg fe/re, Hausman test, xtabond, dynamic panels
references/time-series.mdtsset, ARIMA, VAR, dfuller, pperron, irf, forecasting
references/limited-dependent-variables.mdlogit, probit, tobit, poisson, nbreg, mlogit, ologit, margins for nonlinear
references/bootstrap-simulation.mdbootstrap, simulate, permute, Monte Carlo
references/survey-data-analysis.mdsvyset, svy:, subpop(), complex survey design, replicate weights
references/missing-data-handling.mdmi impute, mi estimate, FIML, misstable, diagnostics
references/maximum-likelihood.mdml model, custom likelihood functions, ml init, gradient-based optimization
references/gmm-estimation.mdgmm, moment conditions, estat overid, J-test

Causal Inference

FileTopics & Key Commands
references/treatment-effects.mdteffects ra/ipw/ipwra/aipw, stteffects, ATE/ATT/ATET
references/difference-in-differences.mdDiD, parallel trends, event studies, staggered adoption
references/regression-discontinuity.mdSharp/fuzzy RD, bandwidth selection, rdplot
references/matching-methods.mdPSM, nearest neighbor, kernel matching, teffects nnmatch
references/sample-selection.mdheckman, heckprobit, treatment models, exclusion restrictions

Advanced Methods

FileTopics & Key Commands
references/survival-analysis.mdstset, stcox, streg, Kaplan-Meier, parametric models
references/sem-factor-analysis.mdsem, gsem, CFA, path analysis, alpha, reliability
references/nonparametric-methods.mdkdensity, rank tests, qreg, npregress
references/spatial-analysis.mdspmatrix, spregress, spatial weights, Moran's I
references/machine-learning.mdlasso, elasticnet, cvlasso, cross-validation

Graphics

FileTopics & Key Commands
references/graphics.mdtwoway, scatter, line, bar, histogram, graph combine, graph export, schemes

Programming

FileTopics & Key Commands
references/programming-basics.mdlocal, global, foreach, forvalues, program define, syntax, return
references/advanced-programming.mdsyntax, mata, classes, _prefix, dialog boxes, tempfile/tempvar
references/mata-introduction.mdMata basics, when to use Mata vs ado, data types
references/mata-programming.mdMata functions, flow control, structures, pointers
references/mata-matrix-operations.mdMatrix creation, decompositions, solvers, st_matrix()
references/mata-data-access.mdst_data(), st_view(), st_store(), performance tips

Output & Workflow

FileTopics & Key Commands
references/tables-reporting.mdputexcel, putdocx, putpdf, LaTeX integration, collect
references/workflow-best-practices.mdProject structure, master do-files, version control, debugging, common mistakes
references/external-tools-integration.mdPython via python:, R via rsource, shell commands, Git
references/filing-issues.mdUser wants to report a Stata skill documentation gap or error to the repository

Community Packages

FileWhat It Does
packages/reghdfe.mdHigh-dimensional fixed effects OLS (absorbs multiple FE sets efficiently)
packages/estout.mdesttab/estout: publication-quality regression tables
packages/outreg2.mdAlternative regression table exporter (Word, Excel, TeX)
packages/asdoc.mdOne-command Word document creation for any Stata output
packages/tabout.mdCross-tabulations and summary tables to file
packages/coefplot.mdCoefficient plots from stored estimates
packages/graph-schemes.mdgrstyle, schemepack, plotplain — better graph themes
packages/did.mdModern DiD: csdid, did_multiplegt, did_imputation (Callaway-Sant'Anna, de Chaisemartin-D'Haultfoeuille, Borusyak-Jaravel-Spiess)
packages/event-study.mdeventstudyinteract, eventdd — event study estimators
packages/rdrobust.mdRobust RD estimation with optimal bandwidth (rdrobust, rdplot, rdbwselect)
packages/psmatch2.mdPropensity score matching (nearest neighbor, kernel, radius)
packages/synth.mdSynthetic control method (synth, synth_runner)
packages/ivreg2.mdEnhanced IV/2SLS: ivreg2, xtivreg2 with additional diagnostics
packages/xtabond2.mdDynamic panel GMM (Arellano-Bond/Blundell-Bond)
packages/binsreg.mdBinned scatter plots with CI (binsreg, binstest)
packages/nprobust.mdNonparametric kernel estimation and inference
packages/diagnostics.mdbacondecomp, xttest3, collinearity, heteroskedasticity tests
packages/winsor.mdWinsorizing and trimming: winsor2, winsor
packages/data-manipulation.mdgtools (fast collapse/egen), rangestat, egenmore
packages/package-management.mdssc 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)

* Event study (uniform timing — must interact with treatment group)
reghdfe y ib(-1).rel_time#1.treated, absorb(id year) vce(cluster id)
testparm *.rel_time#1.treated   // pre-trend test

* 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

Help Improve This Skill

If you produce Stata code with a significant error — wrong syntax, incorrect command usage, or a gotcha you failed to catch — and the issue seems to stem from a gap in these reference files rather than a one-off mistake, consider suggesting to the user that they file an issue on the skill repository. This helps future users.

When to raise this: Only after you've already corrected the error and the user has working code. Frame it as optional: *"I made an error with [X] that I think comes from a gap in the Stata skill documentation. If you'd like, I can help you file an issue or a PR so it gets fixed for everyone."*

When NOT to raise this: If the user is on Claude Haiku, the error is more likely a model capability issue than a documentation gap. In that case, suggest they try Sonnet or Opus for complex Stata work instead of filing an issue.

If the user agrees, read references/filing-issues.md for instructions on writing a good issue report.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.7%
按下载量换算196

Claude

29.34%
按下载量换算161

Cursor

21.67%
按下载量换算119

Gemini CLI

10.32%
按下载量换算57

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/dylantmoore/stata-skill --skill stata 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills