write.dta {foreign}R Documentation

Write files in Stata binary format

Description

Writes the data frame to file in the Stata version 6.0 or 7.0 binary format. Does not write matrix variables.

Usage

write.dta(dataframe, file, version = 6)

Arguments

dataframe a data frame.
file character string giving filename.
version Stata version: 6 and 7 are supported.

Details

The columns in the data frame become variables in the Stata data set. Missing values are correctly handled. Nothing is done with factor levels, which should end up as variable labels. The major difference between versions is that 7.0 allows 32-character variable names.

Value

NULL

Author(s)

Thomas Lumley

References

Stata 6.0 Users Manual, Stata 7.0 Programming manual describe the file formats.

See Also

read.dta, attributes

Examples

data(swiss)
write.dta(swiss,swissfile<-tempfile())
read.dta(swissfile)