Reads a file in Stata version 5–12 binary format into a data frame.
Frozen: will not support Stata formats after 12.
1 2 3
a filename or URL as a character string.
Convert Stata dates to
Use Stata value labels to create factors? (Version 6.0 or later).
For version 8 or later, store information about different types of missing data?
Warn if a variable is specified with value labels and those value labels are not present in the file.
If the filename appears to be a URL (of schemes http:, ftp: or https:) the URL is first downloaded to a temporary file and then read. (https: is only supported on some platforms.)
The variables in the Stata data set become the columns of the data frame. Missing values are correctly handled. The data label, variable labels, timestamp, and variable/dataset characteristics are stored as attributes of the data frame.
By default Stata dates (%d and %td formats) are converted to R's
Date class, and variables with Stata value labels are
converted to factors. Ordinarily,
read.dta will not convert
a variable to a factor unless a label is present for every level. Use
convert.factors = NA to override this. In any case the value
label and format information is stored as attributes on the returned
data frame. Stata's date formats are sketchily documented: if
convert.dates = FALSE and examine the attributes
to work out how to post-process the dates.
Stata 8 introduced a system of 27 different missing data values. If
TRUE a separate list is created with the
same variable names as the loaded data. For string variables the list
NULL. For other variables the value is
where the observation is not missing and 0–26 when the observation is
missing. This is attached as the
"missing" attribute of the
The default file format for Stata 13,
substantially different from those for Stata 5–12.
A data frame with attributes. These will include
"version" and may
Possible versions are
5, 6, 7,
-7 (Stata 7SE, ‘format-111’),
8 (Stata 8 and 9,
10 (Stata 10 and 11, ‘format-114’).
12 (Stata 12, ‘format-115’).
The value labels in attribute
"val.labels" name a table for
each variable, or are an empty string. The tables are elements of the
named list attribute
"label.table": each is an integer vector with
Thomas Lumley and R-core members: support for value labels by Brian Quistorff.
Stata Users Manual (versions 5 & 6), Programming manual (version 7), or online help (version 8 and later) describe the format of the files. Or directly at https://www.stata.com/help.cgi?dta_114 and https://www.stata.com/help.cgi?dta_113, but note that these have been changed since first published.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.