\Header{read.dta}{Read Stata binary files}
\keyword{file}{read.dta}
\begin{Description}\relax
Reads a file in Stata version 5-8 or 7/SE binary format into a data frame.
\end{Description}
\begin{Usage}
\begin{verbatim}
read.dta(file, convert.dates = TRUE, tz = "GMT",
         convert.factors = TRUE, missing.type = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{file}] a filename as a character string.
\item[\code{convert.dates}] Convert Stata dates to \code{POSIXct} class?
\item[\code{tz}] timezone for date conversion
\item[\code{convert.factors}] Use Stata value labels to create factors?
(version 6.0 or later)
\item[\code{missing.type}] For version 8 only, store information about
different types of missing data?
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The variables in the Stata data set become the columns of the data
frame.  Missing values are correctly handled.  The data label,
variable labels, and timestamp are stored as attributes of the data
frame.  Nothing is done with variable characteristics.

Optionally, Stata dates (\%d formats) are converted to \R's
\code{POSIXct} class and variables with Stata value labels are
converted to factors. In any case the value label and format
information is stored as attributes on the returned data frame. 

Stata 8.0 has 27 different missing data values. If \code{missing.type}
is \code{TRUE} a separate list is created with the same variable
names as the loaded data. For string variables the list value is
\code{NULL}. For other variables the value is \code{NA} where the
observation is not missing and 0-26 when the observation is
missing. This is attached as the code{"missing"} attribute of the
returned value.
\end{Details}
\begin{Value}
a data frame
\end{Value}
\begin{Author}\relax
Thomas Lumley
\end{Author}
\begin{References}\relax
Stata Users Manual (versions 5 \& 6), Programming manual (version 7),
or online help (version 8) describe the format of the files
\end{References}
\begin{SeeAlso}\relax
\code{\Link{write.dta}},
\code{\Link{attributes}}
\code{\Link{DateTimeClasses}}
\code{\Link{factor}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(swiss)
write.dta(swiss,swissfile<-tempfile())
read.dta(swissfile)
\end{ExampleCode}
\end{Examples}

