Thanks in advance.

I pass data sets between R and Stata and think dta files would be the best
files for this. To do this I can use package foreign or package memisc. I
mostly use foreign, although have used memisc and this problem mostly didn't
happen, but created errors at other times.

I have a csv data set (and created a test case) with with at least one
column completely missing.  This eventually creates the error. My list of
commands are:

data <- read.csv(file, colClasses = "character")
write.dta(data, newFile)
read.dta(newFile)
Error in read.dta(newFile) :
  a binary read error occurred

The colClasses specificiation is important. This causes the error. Stata 10
and Stata 11 can read the file. Stata 12 is completely lost looking at the
dataset. I know this is an R forum, but the data set acts very strangely in
Stata so I will continue. For my larger data set if I drop one of my
variables, all variables that are all missing are dropped. Either there is
an issue with how the data sets are being saved/stored, or I am doing
something incorrectly by specifying the "character" option in read.csv.

I run R version 2.15.1.

Matt




--
View this message in context: http://r.789695.n4.nabble.com/Read-dta-and-Write-dta-Binary-Data-Error-tp4655754.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]

