.dta files (Stata datasets)

A .dta is a dataset saved by Stata, common in economics, political science and epidemiology.

What is a .dta file?

Stata stores each dataset in a single .dta file: observations in rows, variables in columns, plus variable labels, value labels, display formats such as %td for dates, and notes. Missing values come in 27 kinds: the plain dot and the extended .a to .z, which datasets use to separate "refused" from "not asked".

The format has changed over the years. Stata 13 introduced a new layout with long strings (strL), and Stata 14 switched text to Unicode. Older Stata releases can't open files from newer ones, which is why people sometimes receive a .dta their own Stata refuses.

Replication packages for journal articles, World Bank and DHS-style survey microdata, and many university data archives are distributed as .dta.

Converters for .dta files

How to open a .dta file

In Stata, use File > Open or the use command. If a colleague's newer Stata wrote the file, they can save a copy for older versions with saveold. Without Stata, R reads .dta with the haven package and Python with pandas.read_stata.

No code needed: DTA to Excel gives you a workbook with data, variables and value labels on separate sheets, and DTA to CSV writes three CSV files. Both understand old and new .dta versions, turn Stata dates into readable ones and run in your browser, so the dataset isn't uploaded.

Questions about this format

Why does my Stata say the .dta file is not a Stata file?

Usually because a newer Stata release saved it. Ask the sender to use saveold, or convert it to CSV, which any Stata version can import.

Can SPSS open a .dta file?

Yes. Recent SPSS versions import Stata files through File > Import Data, so a colleague with SPSS can open it too.

Last updated: