.DO

DO File

Stata Do-File
Ask a question
QUICK ANSWER

A .do file is a Stata do-file: a plain-text script of statistical commands used to reproduce an analysis. To view the code, open it in any text editor. To execute it, you need Stata (or a campus Stata license). The file is harmless to open; only run it in Stata if you trust the source.

Developer: StataCorp Category: Developer Files MIME: text/plain
OPENS ON Windows macOS Linux
Related: .MD · .HEX · .XSD · .MAP

On this page

19k+ extensions indexed
Last reviewed Jul 3, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the DO file format?

A .do file is a plain-text script for Stata, the statistical software package developed by StataCorp. It holds a sequence of Stata commands - one per line - that execute in order when the script is run. Do-files are the standard way to write reproducible statistical analyses: instead of typing commands one at a time in the interactive console, researchers collect them in a .do file and run the whole sequence with the do or run command.

The format carries no binary header or magic bytes and uses the text/plain MIME type, so any text editor can open it. Comments use * at the start of a line, // for inline notes, or /* … */ for multi-line blocks. Do-files support the full Stata programming vocabulary: local and global macros, forvalues and foreach loops, conditional logic, and calls to .ado program files.

Do-files work hand-in-hand with .dta Stata datasets - a typical script loads a dataset, cleans and transforms the data, runs statistical models, and exports results. Output is often captured in SMCL log files. Stata's built-in Do-file Editor provides syntax highlighting and a direct run button; Visual Studio Code with the Stata Enhanced extension is a popular alternative for larger projects.

Security & safety

RISK: LOW

A do-file is harmless to open in a text editor, but executing it runs its commands. A malicious Stata do-file could call shell commands (Stata's 'shell'/'!' syntax) or delete files, so review scripts from unknown sources before running them in Stata - the same caution you'd apply to any script.

Format details

in a nutshell
FULL NAMEStata Do-File
DEVELOPERStataCorpsince 1985 (Stata 1.0); do-file workflow standard ever since
MIME TYPEtext/plain
TYPEPlain-text script of Stata statistical commands
This extension is also used by…
  • Java Servlet URL mapping (*.do) - Not a real file - a Struts-era URL suffix mapped to a controller servlet by the web server; nothing to download or open.
  • ModelSim / QuestaSim DO macro - A Tcl-based macro script that automates HDL simulation in FPGA/ASIC and digital-design workflows.

Programs that open DO files

Windows3 apps
Stata Paid Open Stata, then File > Open or type 'doedit' to load the script in the Do-file Editor; run with Ctrl+D. (Commercial; campus licenses are common.)
Notepad Open-source Open directly - a do-file is plain text. Good for reading or quick edits.
Visual Studio Code Free Right-click > Open with Code; install a 'Stata Enhanced' syntax extension for highlighting. Safe way to inspect/edit any .do file without Stata.
macOS2 apps
Stata Paid Open in Stata's Do-file Editor and run with Cmd+Shift+D.
Visual Studio Code Free Open to inspect/edit the script as text.
Linux2 apps
Stata Paid Run 'stata -b do script.do' for batch execution, or use the GUI Do-file Editor.
Any text editor (gedit, Kate, vim) Open-source Open directly; the file is plain text.

Technical details

deep spec
File typePlain-text Stata command script
Developed byStataCorp
MIME typetext/plain
EncodingUTF-8 or ASCII plain text; no binary header or magic bytes
Execution command`do filename.do` or `run filename.do` entered in the Stata command window or another do-file
Comment syntax`*` at line start for a full-line comment; `//` for inline; `/* … */` for multi-line blocks
Line structureOne Stata command per line; long commands continued onto the next line with `///`
Macro supportLocal macros (`local macname`) and global macros (`global macname`) for reusable text substitution
Loop constructs`forvalues` for numeric ranges; `foreach` for lists of items such as variable names or file paths
Conditional logic`if` qualifiers on individual commands and `if`/`else` block control flow
Typical useReproducible data cleaning, statistical modelling, and batch output generation
Related formats`.ado` (Stata programs), `.dta` (Stata datasets), `.smcl` (Stata log files), `.sthlp` (Stata help files)
Operating systemsWindows, macOS, Linux - wherever Stata is installed
Editor supportStata built-in Do-file Editor (syntax highlighting, direct run); VS Code with Stata Enhanced extension; any plain-text editor
Released1985 (Stata 1.0); do-file workflow standard ever since
Specificationwww.stata.com

DO conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with DO files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about DO files.

Frequently asked questions

How do I open a .do file without Stata?
Any text editor opens it - VS Code or Notepad++ with a Stata syntax extension makes it readable. You only need Stata (or an alternative with a Stata engine) to actually execute the analysis.
How do I run a Stata do-file?
In Stata: open it in the Do-file Editor and press Ctrl+D (Cmd+Shift+D on Mac), or type: do "path\script.do" in the command window. From a terminal: stata -b do script.do runs it in batch mode.
Can I convert a Stata .do file to R or Python?
Not automatically - there is no reliable translator. The do-file documents the analysis steps; an R/Python version has to be rewritten by hand. The dataset (a .dta file) can be imported into R/pandas directly.
What's the difference between a .do and a .ado file?
A .do file is a script you run for a specific analysis; an .ado file defines a reusable Stata command/program that Stata loads automatically when you call it by name.
Why did I receive a .do file with a .dta file?
That's a Stata replication package: the .do is the analysis script and the .dta is the dataset it operates on. Open the .dta in Stata, then run the .do to reproduce the results.

References

1Stata documentation - [U] 16 Do-fileswww.stata.com
2StataCorp - official sitewww.stata.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.EXEWindows Executable (Portable Executable)
5.DATProgram Data File (generic)
6.MDMarkdown Document
7.TMPTemporary File
8.M4AMPEG-4 Audio File
9.BINCD/DVD Disc Image (BIN/CUE)
10.ODTOpenDocument Text

Related extensions

.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File
.NUPKGNuGet Package

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z