Learn R Programming

foreign (version 0.4-3)

write.dta: 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, filename,version=7)

Arguments

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

Value

  • NULL

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.

References

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

See Also

read.dta,attributes

Examples

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

Run the code above in your browser using DataLab