Project sharing | Stata All in One
logo
Table of Contents
Stata All in One
One VS Code extension tailored for Stata users
| Version: 0.3.5 | Author: Zihao Viston Wang | Translate: 中文版本 |
All-in-one Stata experience: Code Execution + Syntax Highlighting + Code Completion + Smart Outline + Data Viewing + AI Skill!
Ready out of the box!
Natively integrated into VS Code—no need to configure external environments like Python or Node.js.
Stata All in One is derived from Stata Outline, expanded with new features and improvements.
Sponsors
-
First, my thanks go to RedNote user Rich**d, WeChat users M*k*, 柿**橙, and the anonymous user who commented “功能强大且配置简单的插件,谢谢!”, and Buy Me a Coffee supporters LB**PG@gmail.com and ol***ba@gmail.com for their generous contributions and continued support of this project.
-
Above all, I am deeply grateful to the Agricultural Economics and Management Innovation Team at Northwest A&F University for supporting my research, providing funding, and helping promote and publicize this project.
-
I am also sincerely grateful to Assoc. Prof. Yujun Lian and the lianxh.cn team for their patient guidance and publicity support.
-
Finally, I thank Stata’s officially authorized distributor Beijing Uone Info&Tech Co.,Ltd (Uone-Tech) for its support in promoting and publicizing this project.
Features
⚠️ Features marked with 🛠️ require Stata 17 or later and a
STATA.LIClicense file. Please support genuine Stata software to enjoy the full experience. You can contact Stata Corp, LLC’s officially authorized partner Beijing Uone Info&Tech Co.,Ltd (Uone-Tech) to purchase genuine Stata software or request a trial.
1. AI Skill (Experimental) 🛠️
- Let AI Agents Run Stata Code: Install the standalone native
stata-ai-skillso AI coding tools (Claude Code, Cursor, Codex CLI, Open Code, OpenClaw, etc.) can run Stata through a Rust background service. - Native Local Service: Once installed, the AI Skill runs through its native executable and local service.
- Leave the setup to AI: Click the
AIbutton in the editor toolbar, copy the prompt, and paste it into your AI tool. The prompt links to the onlineinstallation.mdthrough Gitee and GitHub. - Lightweight Extension: AI Skill executables are installed only when needed and are no longer bundled with this extension.
2. Code Execution (Stata Interaction)
- Platform Support: Seamlessly integrates with Stata on both macOS and Windows without requiring additional extensions.
- Two Run Modes:
- Embedded Console (default) 🛠️: Run and display Stata output directly within VS Code! Including command results, error messages, command window output, and graph output — a true all-in-one IDE experience.
- External App: Continue using the traditional approach of sending code to the Stata GUI, for users who prefer Stata’s native interface. Windows now uses Stata COM Automation, delivering significantly better performance than the previous PowerShell-based implementation.
- Multi-Scenario Execution Strategies:
- Section Execution: When the cursor is on a header line (e.g.,
** # Title), click the ▶️ button or pressCtrl/Cmd + Dto execute all code from that header to the next same-level or higher-level header (i.e., the entire section). - Single Line Execution: When the cursor is on a regular code line (no selection), click the ▶️ button or press
Ctrl/Cmd + Dto execute only that specific line. - Selected Code Execution: When multiple lines are selected, click the ▶️ button or press
Ctrl/Cmd + Dto execute the selected lines. Supports fuzzy selection — no need to precisely select the first or last line of a code segment; the system automatically captures and runs all lines covered by the selection.
- Section Execution: When the cursor is on a header line (e.g.,
3. Enhanced Syntax Highlighting & Code Completion
- Full Syntax Highlighting and Code Completion Support: Integrates Stata Enhanced syntax engine1, providing precise syntax highlighting and code completion for
.dofiles (under MIT License). - Custom Command Highlighting: Supports highlighting for commonly used third-party commands (e.g.,
reghdfe,ivreghdfe,gtools), freely configurable in settings. - Dataset Variable Autocompletion: (After running code once) Provides intelligent autocomplete suggestions based on the current dataset when typing variable names in the editor and console, boosting coding efficiency.
4. Smart Outline & Structural Navigation
- Multi-level Outline Recognition: Automatically detects comment lines from
**#to**######as hierarchical headers, supporting up to 6 levels.- Shortcuts:
Ctrl/Cmd + 1-6to quickly convert to the corresponding header level;Ctrl/Cmd + 0to revert to a standard code line.
- Shortcuts:
- Cursor Auto-Follow: The outline view automatically highlights and navigates to the corresponding section as the cursor moves in the editor.
- Setup: Click the “···” button in the top-right of the Outline view and check “Follow Cursor”.2
- Multi-level Numbering: Optional display of logical numbering (e.g.,
1.1,1.2.1) within the outline (must be enabled in settings). - Auto-Sync Numbering: When enabled, the extension automatically adds or removes numbering directly within the
.dofile based on the outline structure. program defineBlock Recognition: Displays program names in the outline view for easy navigation and management of custom programs.
5. Data Viewer 🛠️
- Click to View: Click a
.dtafile in the VS Code Explorer to open it in the newData Viewerpanel.- Variable Info: Variable table displays metadata such as name, label, and type.
- Data Browsing: Supports lazy loading of rows and columns — easily browse large datasets right in VS Code without opening Stata.
- View After Run: After running code, instantly view results in the
Data Viewerwithin theConsolepanel. Works in both run modes — no need to switch back and forth. - Data Filtering: Provides Stata-style filtering for quickly locating subsets of data.
- Built-in
br/browse: In Embedded Console mode, runbrorbrowsefrom either the editor or Console command input to open the built-in Data Viewer. The command and a localized confirmation remain visible in Console, while any followingvarlist,if,in, andnolabelclauses are applied directly as viewer filters. External App mode keeps Stata’s originalbr/browsebehavior unchanged.
6. Efficient Separator Lines & Styling
- Quick Insertion: Supports various symbols to significantly enhance code readability.
- Standard Separators: Use
Ctrl/Cmd + Symbolto quickly insert separator lines:Ctrl/Cmd + -(Dash) |Ctrl/Cmd + =(Equal) |Ctrl/Cmd + Shift + 8(Asterisk)
- Custom Separators:
Ctrl + Alt + S(Windows) |Ctrl + Cmd + S(macOS), where S stands for “Separator”.- After pressing the shortcut, simply input your desired character to generate the corresponding separator line.
- Standard Separators: Use
- Intelligent Wrap Mode:
- Blank Line Insertion: Generates a full-width separator line (length adjustable in settings).
- Non-blank Line Insertion: Pressing the shortcut once inserts above the line; pressing it again inserts below, creating a “wrapped” effect.
- Header Decoration: Select some characters of a header and press the shortcut to generate a title with balanced decorative symbols (e.g.,
**# === Title ===), without affecting outline recognition.- Centered Header: If using Header Decoration + Custom space separator, the header content will be automatically centered.
7. More Features
-
Enhanced Embedded Console 🛠️
-
Graph Output
- Direct Display: Render Stata graph output directly in the embedded console.
- Export Options: Save graphs as SVG, PNG (configurable DPI), or copy to clipboard.
- Fullscreen View: Click a graph to view it in fullscreen mode for detailed inspection.
-
Progress Display
- Command Execution Status: For long-running commands like
bootstrap,bdiff, andxthreg, the console shows real-time progress (e.g. 50/2000) and estimated time remaining. Other commands display elapsed time.
- Command Execution Status: For long-running commands like
-
Custom Font:
- Online (Default): Load Maple Mono for Latin text and Maple Mono NF CN for Chinese text.
- Font Settings: Use
stata-all-in-one.consoleFontModeandstata-all-in-one.consoleCustomFontFamilyto customize the console font for a better reading experience.
-
-
Enhanced Comments
- Toggle Comments: Quickly toggle line comments using
Ctrl/Cmd + /. - Optional Styles: Defaults to
//, with support for switching to other valid Stata comment delimiters in settings.
- Toggle Comments: Quickly toggle line comments using
-
Built-in Help
- Show Help Text: For example, select
regressand pressCtrl/Cmd + Shift + H. In External App mode, this opens Stata’sregresshelp page; in Embedded Console mode, the help text is displayed directly in the console. - Hover Help: Hover over a Stata command to see help information, with automatic filtering of non-practical commands like
#delimit,using, etc.
- Show Help Text: For example, select
-
Smart Line Break
- One-Key Line Break: Use
Shift+Enterto insert Stata line continuation symbol///at the cursor position. - Smart Indentation: Automatically indent by 4 spaces
- One-Key Line Break: Use
-
Safe Rename Mode
- Rename Variable: Select a variable and press
F2to rename all occurrences in the current document. - Smart Validation: Automatically validates the new name to ensure it follows Stata naming rules and does not conflict with built-in commands or keywords.
- Command Protection: Intelligently prevents renaming Stata commands (e.g.,
reghdfe,outreg2) and their options (e.g.,absorb,ctitle).
- Rename Variable: Select a variable and press
-
Auto
cdto Do File Directory- Auto Working Directory: When enabled, automatically sets Stata’s working directory to the do file’s location on first launch.
-
Quick Settings
- Settings Button: Click the gear icon in the editor title bar to quickly access Stata All in One settings.
Keyboard Shortcuts
Click here to view the complete list of keyboard shortcuts.
Installation
Install from Extension Marketplace
- VS Code: Search for “Stata All in One” in extensions and install.
Download and Install (for Cursor, Trae and other VSCode-based IDEs)
- Download
stata-all-in-one-x.x.x.vsixfrom either source: - Open Extensions panel in your editor →
...→Install from VSIX.... - Select the downloaded
.vsixfile to complete installation.
Configuration
Search for “Stata All in One” in VS Code settings and configure:
AI Skill
Click the AI button in the Stata editor toolbar to copy a prompt containing Gitee and GitHub links to the online installation.md. After installation, your AI coding tool follows the installed Skill’s SKILL.md for service startup, status checks, Stata configuration, and subsequent operations.
Configure from Stata
If automatic discovery cannot find Stata, choose Stata not found? Configure it directly from Stata. The extension provides two commands to copy and run in a separately opened Stata application outside VS Code:
net install saio, from("<extension>/stata/saio") replace
saio setup
The saio package supports Stata 13 and later without Java, Python, curl, or third-party dependencies. It connects only to the extension’s persistent local service on 127.0.0.1:16886–16895, prints the existing configuration first, and asks before replacing an existing setup. Use saio status for a read-only check or saio setup, force for unattended reconfiguration. VS Code blocks saio in the editor and Embedded Console because an already usable VS Code Stata session does not need this setup command.
Code Execution
-
Run Mode (
stata-all-in-one.runMode)embeddedConsole(default): Run code in the built-in Console | Stata All in One panel within VS Code, with direct output viewing and interaction.externalApp: Send code to the system-installed Stata application for execution.
-
Stata Version on macOS (
stata-all-in-one.stataVersionOnMacOS)- Stata runtime version. When empty, the extension detects installed versions at startup for up to 3 seconds, preferring the highest numeric version and then
StataMP,StataSE,StataBE, andStataIC. If detection fails, configure directly from the running Stata instance. The initializer then verifies the exact.app, Console dylib, andstata.lic, initializes the Embedded Console when possible, and reports the result once in a central dialog.
- Stata runtime version. When empty, the extension detects installed versions at startup for up to 3 seconds, preferring the highest numeric version and then
-
Stata Path on Windows (
stata-all-in-one.stataPathOnWindows)- Path to Stata executable file (e.g.,
C:\Program Files\Stata17\StataMP-64.exe). When empty, the extension runs the bundledscripts/discover_stata_windows.batregistry probe at startup for up to 5 seconds. The same BAT can be run independently to generatestata-discovery-report.jsonfor troubleshooting. If detection fails, configure directly from the running Stata instance. The initializer then verifies the EXE, Console DLL, andstata.lic, initializes the Embedded Console when possible, and reports the result once in a central dialog.
- Path to Stata executable file (e.g.,
-
Close Stata Other Windows Before Sending Code (Windows) (
stata-all-in-one.closeStataOtherWindowsBeforeSendingCode)true: Close Stata helper windows (such as Viewer/Data Editor) before sending run commands.false(default): Keep those windows open and send code directly.
-
Auto cd to Do File Directory (
stata-all-in-one.cdToDoFileDir)true(default): Automatically set Stata’s working directory to the do file’s location on first launch.false: Stata’s working directory is not changed on startup.
-
Show Action Buttons (
stata-all-in-one.showActionButtons)true(default): Show the “Bug Report” and “Stata AI Skill” buttons in the editor title bar.false: Hide both buttons.
-
Show Sponsor Button (
stata-all-in-one.showSponsorButton)true: Show the “Sponsor” button in the Stata editor title bar.false(default): Hide the button.
-
Enable Ctrl+Shift+D for Run Shortcut (
stata-all-in-one.enableCtrlShiftD)true: UseCtrl/Cmd+Shift+Das the run code shortcut.false(default): Use the defaultCtrl/Cmd+Dshortcut.
Embedded Console
- Console Font Mode (
stata-all-in-one.consoleFontMode)online(default): Load Maple Mono for Latin text and Maple Mono NF CN for CJK text. 3editor: Follow the editor font, falling back to the system monospace font.system: Use the system monospace font directly.custom: Use the custom font specified below.
-
Console Custom Font Family (
stata-all-in-one.consoleCustomFontFamily) - When font mode is set tocustom, the CSSfont-familylist used by the console. - Example:"Maple Mono NF CN", Menlo, Monaco, monospace -
Graph Export DPI (
stata-all-in-one.graphPngDpi) - DPI value for saving embedded console graphs as PNG. Default600, range 72–1200.
Syntax Highlighting and Code Completion
- Custom Command Highlighting (
stata-all-in-one.customCommands)- User-defined Stata commands to highlight as keywords (array of strings). Default:
reghdfe. - Example:
["reghdfe", "ivreghdfe", "gtools", "winsor2", "outreg2"] - Requires reloading window after configuration.
- User-defined Stata commands to highlight as keywords (array of strings). Default:
Hover Help
-
Enable Hover Docs (
stata-all-in-one.enableHoverDocs)true(default): Show official Stata help information when hovering over Stata commands.false: Disable hover help.
-
Additional ADO Paths (
stata-all-in-one.additionalAdoPaths)- Extra Stata ADO paths for scanning help files of community-contributed commands.
- Example:
["/Users/username/ado/personal", "C:\\Users\\username\\ado\\personal"]
Outline & Navigation
-
Display Multi-level Numbering (
stata-all-in-one.numberingShow)true: Outline displays1.1,1.2.1style numbering.false(default): Displays original headings.
-
Auto-update Heading Numbering (
stata-all-in-one.numberingAdd)true: When numbering is enabled, automatically update section titles in.dofiles to include numbers.false(default): Only displays numbering in outline, doesn’t modify file.
Note: Changes to
numberingShow,numberingAdd, andcustomCommandsrequire reopening.dofiles to take effect. WhennumberingAddis disabled, existing numbering in.dofiles will be automatically removed.
Code Style
-
Comment Style (
stata-all-in-one.commentStyle)//(default): Comment style used for toggling comments. Options include//,*, or/* ... */
-
Separator Length (
stata-all-in-one.separatorLength)- Total character length of the separator line (including the
** #prefix and separators). Default:60
- Total character length of the separator line (including the
- Separator Symmetric (
stata-all-in-one.separatorSymmetric)true: Add**at the end of separator lines to ensure visual symmetry (e.g.,** === Title === **).false(default): Separator lines without the suffix.
Buy me a coffee
If this extension has been helpful to you, feel free to scan the Alipay (left), WeChat (middle), or Buy Me a Coffee (right) QR code below to support ☕
Changelog
| Version | Changes | Release Date |
|---|---|---|
| 0.3.5 | Moved Stata AI Skill online, reducing the Stata All in One extension package to 2.48 MB; fixed Tab recognition between code tokens. | 2026-07-22 |
| 0.3.4 | Rebuilt the Data Viewer with direct .dta and Console-memory access and improved native stability on macOS and Windows. |
2026-07-22 |
| 0.3.3 | Improved Embedded Console command compatibility and multi-line browse routing, and refined which output rendering. |
2026-07-21 |
| 0.3.2 | Focused on improving Stata initialization and intelligent autocomplete, while adding multi-format Console export, built-in data browsing commands, and Stata AI Skill v1.1 | 2026-07-17 |
| 0.3.1 | Streamlined Stata startup setup with automatic installation discovery and runtime checks to minimize manual configuration | 2026-07-13 |
| 0.3.0 | Stable release: Fixed known issues from the preview releases | 2026-07-06 |
See CHANGELOG.md for full version history.
-
Stata Enhanced syntax engine was developed by Kyle Barron, providing comprehensive support for the Stata language. This extension follows the MIT License. Thanks to Kyle Barron for his contribution! ↩︎
-
Sorry~ This is a VS Code GUI setting, I cannot control it through the extension. ↩︎
-
Font credits: subframe7536/maple-font, fontsource, and ZeoSeven Fonts (443, 442). ↩︎
Click to view full image