What is a .dta file?
Stata Dataset · Data · StataCorp · 1985
A .dta file is a Stata dataset: the native data format of the Stata statistics package, widely used in economics, epidemiology and social science. It stores the table plus labels, value codes and metadata.
What is a .dta file used for?
Stata's format is versioned, and files written by a newer Stata do not open in older releases, a constant headache in research teams; Stata's saveold command bridges the gap. Modern versions of the format begin with an XML-like <stata_dta> marker, while older releases used a bare binary header, so there is no single magic number across versions.
The rich metadata (variable labels, value labels, missing-value codes) is why researchers exchange .dta instead of CSV: the meaning of coded answers travels with the data.
How to open a .dta file
The .dta format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .dta file.
Windows
- Stata
- R (haven)
- Python (pandas.read_stata)
macOS
- Stata
- R (haven)
- Python (pandas)
Linux
- Stata
- R (haven)
- Python (pandas)
How to convert a .dta file
You can convert a .dta file to csv, xlsx, sav, parquet using a conversion tool or the export menu of an app that opens it.
.dta file signature (magic bytes)
Programs recognise a .dta file by the bytes at the start of the file, not by its name. These are the signatures for Stata.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | no fixed magic; structure defined by a schema or header |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .dta file?
A .dta file is a Stata dataset: the native data format of the Stata statistics package, widely used in economics, epidemiology and social science. It stores the table plus labels, value codes and metadata.
How do I open a .dta file without Stata?
pandas.read_stata() in Python or the haven package in R read .dta files directly, including labels. Both are free.
Why won't my .dta file open in my Stata version?
It was saved by a newer Stata. Ask the sender to use saveold to write an older format version, or read it with R/pandas, which handle most versions.
How do I convert .dta to CSV or Excel?
Load it with pandas or haven and write CSV/XLSX. Note that value labels (coded categories) may need exporting separately if you want the text answers.
Related formats
Sources
Details on this page were checked against authoritative references: