DTA File Documentation
Summary
A DTA file is a data file. By far the most common kind is a Stata dataset, the binary data format of the Stata statistics package (StataCorp), which holds one rectangular table of variables and observations; its MIME type is application/x-stata-dta. Other programs also use .dta as a plain “data” suffix, so identify a file by where it came from. You do not need Stata to read a Stata .dta: R’s haven, Python’s pandas and free web viewers open it and export to CSV.
Technical details
| Feature | Value |
|---|---|
| Extension meaning | Generic “data” suffix; most often a Stata dataset |
| File extension | .dta |
| Primary format | Stata Data File |
| MIME type (Stata) | application/x-stata-dta |
| Format type | Binary statistical dataset (one rectangular table) |
| Developer (Stata) | StataCorp LLC |
| Introduced (Stata) | Stata 1.0, 1985 |
| Format versions | 104–121 map to Stata 8 through 19 |
| Header (Stata 13+) | XML-tagged binary starting with <stata_dta> |
| Header (Stata 8–12) | No ASCII signature; first byte is the format-version number |
| Open standard | Partial — proprietary but publicly documented by StataCorp |
| Stores | Variable names, storage types, variable labels, value labels, data matrix |
| Other uses of .dta | Turbo Pascal data tables; various game/app data files |
| Free readers | R (haven), Python (pandas), GNU PSPP, PondPilot (web) |
| Typical conversions | CSV, XLSX, SAV (SPSS), RData |
| Related extensions | .csv, .sav, .sas7bdat, .rdata, .xlsx, .dat |
| Specification URL | stata.com/manuals/pfileformatsdta.pdf |
What is a DTA file?
A .dta file is a data file: the extension is a generic “data” suffix rather than the mark of a single format. In practice one meaning dominates. Most .dta files are Stata datasets, the native data format of Stata, a commercial statistical-analysis package from StataCorp used heavily in economics, epidemiology, political science and the wider social sciences since the 1980s. When someone runs into a .dta today, it is almost always because a collaborator, a journal replication package or a public data archive (ICPSR, the World Bank, DHS) distributed research data in Stata format.
A few other programs have also used .dta for their own purposes: Borland Turbo Pascal stored data tables under it, and assorted games and applications append it as a plain data suffix to files only their own code understands. Those files share nothing but the three letters. The reliable first step is therefore identification, not conversion: check the folder the file came from, or look at its opening bytes. The rest of this article focuses on the Stata dataset, since that is the format with a documented structure and the one behind essentially all “how do I open a .dta” questions.
What a Stata dataset stores: header, descriptors, labels and data
A Stata .dta holds a single rectangular dataset — variables as columns, observations as rows — together with the metadata that makes the numbers meaningful. Conceptually the file is five parts in order:
Stata .dta (logical layout)
+---------------------+
| header | format/release version, byte order (endianness),
| | number of variables, number of observations,
| | dataset label, timestamp
+---------------------+
| variable descriptors| per column: name, storage type
| | (byte/int/long/float/double/strN/strL),
| | display format, sort order
+---------------------+
| variable labels | a human-readable description per column
+---------------------+
| value labels | maps numeric codes to text (e.g. 1 = "Male")
+---------------------+
| data matrix | the observations, row by row, in binary
+---------------------+
The two label sections are what distinguish a Stata dataset from a plain table. Variable labels attach a sentence of description to each column (so a column named inc can read “Household income, 2019 USD”), and value labels map the stored numeric codes to their categories (so the 1s and 2s in a sex column display as “Male” and “Female”). The header also records the file’s byte order, because Stata datasets can be little- or big-endian, and any reader must respect the flag to decode the numeric data correctly.
Format versions and the <stata_dta> marker
Stata stamps each file with an internal format (release) version, and that number decides how the file must be parsed. The mapping runs from format 104–115 for Stata 8–12, format 117 for Stata 13, up through format 121 for Stata 19. The important dividing line is Stata 13 (2013): from format 117 onward the file is an XML-tagged binary that literally begins with the text <stata_dta>, wrapping each section in tags such as <header>, <map>, <variable_types> and <data>. Older files (formats 104–115) have no text header at all; their first byte is simply the numeric version, which is why an old .dta looks like binary noise in a text editor while a new one shows readable tags.
Version compatibility runs one way. A newer Stata opens older files without complaint, but an older Stata may refuse a file written by a newer release unless the sender re-exports it with the saveold command targeting the older format. This is the single most common reason a .dta “won’t open” for someone who does have Stata.
Reading a Stata .dta without a Stata licence
Because StataCorp publishes the format, free tools read it fully, labels and all. In R, the tidyverse haven package loads a dataset with read_dta("file.dta") and keeps variable and value labels as column attributes. In Python, pandas.read_stata("file.dta") does the same and hands back a DataFrame you can write out with .to_csv() or .to_excel(). GNU PSPP, a free SPSS-like program, imports Stata files for viewing and analysis, and the browser-based PondPilot viewer opens Stata 8–19 locally and exports CSV, Parquet, JSON or Excel without uploading the data anywhere.
The recurring export task is DTA to CSV, and it carries one trap worth knowing: CSV has no concept of value labels, so a categorical column exported naively comes out as the underlying numeric codes rather than the text categories. To keep the readable labels, decode them first — Stata’s decode, or mapping the labels in R/pandas — before writing the CSV. Losing labels silently on export is a far more common problem with .dta files than any question of software support.
When a .dta is not a Stata file
If a Stata reader rejects the file with a format error, it is probably one of the other meanings. A Turbo Pascal .dta data table is readable only inside that legacy environment. Game and application .dta files are private formats whose layout is undocumented, so there is no general tool for them: the program that wrote the file is the program that opens it. In these cases the honest answer is that the extension tells you nothing about the contents. Inspect the header bytes (a genuine modern Stata file announces itself with <stata_dta>), check the application the file shipped with, or run an identifier like TrID. Do not assume every .dta is a dataset, and be wary of “universal DTA viewer/repair” download sites, which tend to bundle adware and cannot actually decode a private application format.
Frequently asked questions
How do I open a Stata .dta file without Stata?
Use the free PondPilot web viewer (it opens Stata 8–19 in the browser and exports CSV or Excel), or read it in R with haven::read_dta() or in Python with pandas.read_stata(). GNU PSPP can also import it. All of these preserve the variable and value labels that a Stata dataset carries.
Why won’t my older Stata open this .dta?
It was saved by a newer Stata version, and Stata only opens files at or below its own format version. Ask the sender to re-save it with the saveold command targeting your release, or read it in R, Python or PondPilot, which handle all recent format versions.
Do I lose my labels when exporting a Stata .dta to CSV?
Often yes. CSV stores only plain values, so categorical columns export as their underlying numeric codes unless you decode the value labels first. Apply the labels in Stata (decode) or map them in R/pandas before writing the CSV if you need the text categories preserved.
References
- StataCorp — Stata .dta file format specification (PDF)
- haven (tidyverse) — read and write Stata, SPSS and SAS files in R
- pandas — read_stata documentation
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.