Skip to content
Automation
Skill

/stata-python-translation

Stata-to-Python translation for data analysis. Maps Stata commands (reghdfe, xtreg, ivregress, margins, esttab, svy:) to Python (polars, pyfixest, statsmodels, svy). Use when user has Stata background or requests Stata-equivalent code comments.

From plugin
auto-empirical-research-skills
5k200 skills

Claude Code

$ npx -y skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill stata-python-translation --agent claude-code

SKILL.md

stata-python-translation.SKILL.md
name: stata-python-translation
description: >-
  Stata-to-Python translation for data analysis. Maps Stata commands (reghdfe, xtreg, ivregress, margins, esttab, svy:) to Python (polars, pyfixest, statsmodels, svy). Use when user has Stata background or requests Stata-equivalent code comments.
metadata:
  audience: research-coders
  domain: research-methodology
  skill-last-updated: "2026-03-28"

Stata-to-Python Translation Skill

Stata-to-Python translation reference for quantitative social science data analysis. Maps Stata commands and packages (reghdfe, xtreg, ivregress, margins, esttab, svy:, graph twoway) to DAAF Python equivalents (polars, pyfixest, statsmodels, linearmodels, marginaleffects, svy, plotnine). Use when user mentions Stata background, requests Stata-equivalent code comments, needs to understand Python analysis code from a Stata perspective, or wants to translate Stata data analysis concepts to Python. Covers paradigm differences, command-by-command operation translations, regression modeling, causal inference, visualization, and workflow adaptation.

Cross-language translation reference for researchers moving between the Stata and Python data analysis ecosystems. This skill maps Stata commands, idioms, and workflows to their DAAF Python equivalents so that Stata-background users can audit, understand, and learn from DAAF-produced code, and so that code-producing agents can annotate their output with Stata equivalents when directed.

This skill is a **routing hub** -- it provides overview tables, decision trees, and directs readers to the detailed reference files listed below. The reference files contain the exhaustive command-by-command mappings, code examples, and edge-case documentation.

What This Skill Does

  • Maps the Stata command universe to DAAF's Python stack across data management, regression modeling, causal inference, surveys, visualization, and workflow tooling
  • Provides a structured annotation protocol for agents to add inline Stata-equivalent comments to Python code
  • Identifies paradigm gaps where Stata and Python diverge fundamentally, so users know where to expect friction

**Use cases:**

1. Stata user auditing DAAF Python code and needing to understand what operations are being performed 2. Agent annotating code with Stata-equivalent comments for a Stata-background researcher 3. Stata user learning Python for data analysis and needing a conceptual bridge 4. Translating a specific Stata command or do-file idiom to its Python equivalent 5. Understanding where Stata commands have no direct Python equivalent (and what the workaround is)

How to Use This Skill

Reference File Structure

Each topic in `./references/` contains focused documentation:

| File | Purpose | When to Read | |------|---------|--------------| | `paradigm-differences.md` | Core language and paradigm differences (single-dataset model, missing values, value labels, macros, by:/_n/_N) | Encountering fundamental Stata-vs-Python confusion | | `data-management.md` | gen/replace/keep/drop/sort/merge/append/reshape/collapse/egen to polars | Reading or writing data manipulation code | | `strings-dates-labels.md` | String functions, date epoch, value labels, encode/decode | Working with string, date, or categorical columns | | `regression-modeling.md` | regress/areg/reghdfe/xtreg/ivregress/logit/probit/margins/test/esttab to pyfixest/statsmodels/linearmodels | Reading or writing regression code | | `causal-inference.md` | DiD/RDD/IV/event studies/synthetic control/matching | Working with causal inference methods | | `visualization.md` | graph twoway/bar/box/histogram to plotnine/plotly | Reading or writing visualization code | | `survey-spatial-ml.md` | svy: commands, spatial data, machine learning | Working with surveys, spatial data, or ML | | `workflow-environment.md` | Do-files/log/macros/ado/ssc to Python/DAAF execution model | Adapting to DAAF's execution model | | `external-resources.md` | Curated guides and tutorials with provenance | Seeking additional learning materials | | `gotchas.md` | Common Stata-user mistakes in Python | Debugging or reviewing code from Stata perspective |

Reading Order

1. **Stata user auditing DAAF code:** `paradigm-differences.md` then the relevant domain file (e.g., `data-management.md` for wrangling, `regression-modeling.md` for models) then `gotchas.md` 2. **Agent annotating code with Stata equivalents:** Agent Code Annotation Protocol section below, then the relevant domain file for the code being annotated 3. **Learning Python from Stata background:** `paradigm-differences.md` then `data-management.md` then `workflow-environment.md` then `external-resources.md` 4. **Looking up a specific Stata command translation:** Quick Decision Trees below, then the relevant reference file

Quick Decision Trees

"How do I do X from Stata in Python?"

What kind of Stata command?
+-  Data management (gen, replace, keep, drop, merge, reshape, collapse)
|   +-- ./references/data-management.md
+-  Group operations (by:, bysort, egen)
|   +-- ./references/data-management.md
+-  Regression / estimation (regress, areg, reghdfe, xtreg, logit, probit)
|   +-- ./references/regression-modeling.md
+-  Post-estimation (margins, test, lincom, nlcom, predict, esttab)
|   +-- ./references/regression-modeling.md
+-  Causal inference (diff, did_multiplegt, rdrobust, teffects, synth)
|   +-- ./references/causal-inference.md
+-  Surveys (svyset, svy:)
|   +-- ./references/survey-spatial-ml.md
+-  Plotting (graph twoway, histogram, graph bar)
|   +-- ./references/visualization.md
+-  String/date manipulation (substr, strpos, date, mdy)
|   +-- ./references/strings-dates-labels.md
+-  Value labels (label define, encode, decode)
|   +-- ./references/strings-dates-labels.md
+-- Programming (local, global, foreach, forvalues, tempvar, preserve)
    +-- ./references/workflow-environment.md

"Why does this Python code look different from Stata?"

``

Read more
@brycewang-stanford
Ships withauto-empirical-research-skills

## 🔥 力荐 · StatsPAI — Stata 与 R 的 Python 平替,为 AI Agent 而生 🔁 Stata / R 平替:reghdfe、csdid、rdrobust、synth、fixest、did 等常用命令在 Python 中一站式替代,一个 import statspai as sp 搞定 DID / RD / IV / SCM / DML / matching 🤖 面向 Agent 设计:结构化结果对象 + 内置 MCP Server,Claude / Codex

Stars on GitHub

Momentum

stars in total
5.0k
Star history of brycewang-stanford/Auto-Empirical-Research-Skills on GitHub, a chart by star-history.com

More skills from other plugins.

agent-builder

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, and…

n8n2w209k
@n8n-io@n8n-ioInstall Skill
browser-use

browser-use

Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…

@browser-use@browser-useInstall Skill
add-anydoc

add-anydoc

Add local office-document-to-Markdown conversion to NanoClaw agent containers with the pinned Firecrawl AnyDoc CLI. Use when…

@nanocoai@nanocoaiInstall Skill

Questions about stata-python-translation.

Which coding agents can use stata-python-translation?
stata-python-translation installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.