Re: [R] importing .dta files

2007-06-15 Thread Thomas Lumley
On Fri, 15 Jun 2007, Chris Linton wrote:

> I'm trying to read in a Stata file but I've never used this function (
> read.dta).  It's the only one that seems to come close to working, but I
> keep getting this error:
>
>> data<-read.dta("C:/Documents and
> Settings/Chris/Desktop/S4412/catestscores.dta")
> Error in read.dta("C:/Documents and
> Settings/Chris/Desktop/S4412/catestscores.dta",  :
>a binary read error occurred
>
>
> There's little chance the data is corrupt considering it came from my
> professor and he used the data earlier.  So, either I'm doing something
> wrong or R just doesn't like to read in Stata files.  If it's a problem with
> R, how can I easily convert the file without purchasing Stata?
>

R does read Stata files -- I use this facility frequently.  It's hard to 
tell why it isn't working in your case, since we don't know anything about 
the file, your version of R, version of Stata, etc (we can guess you are 
on windows from the file name).

The error message implies that the file was found, and that it started 
with the right sequence of bytes to be a Stata .dta file, but that 
something (probably the end of the file) prevented R from reading what it 
was expecting to read.

This is why (in the absence of any further information) the natural 
suspicion is that the file is corrupt.  It is possible that we have 
misunderstood some unusual possibility in the Stata file format -- this 
has happened once before -- but it is fairly well documented.  In any 
case, there is not much that can be done without more information.


-thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] importing .dta files

2007-06-14 Thread Chris Linton
I'm trying to read in a Stata file but I've never used this function (
read.dta).  It's the only one that seems to come close to working, but I
keep getting this error:

> data<-read.dta("C:/Documents and
Settings/Chris/Desktop/S4412/catestscores.dta")
Error in read.dta("C:/Documents and
Settings/Chris/Desktop/S4412/catestscores.dta",  :
a binary read error occurred


There's little chance the data is corrupt considering it came from my
professor and he used the data earlier.  So, either I'm doing something
wrong or R just doesn't like to read in Stata files.  If it's a problem with
R, how can I easily convert the file without purchasing Stata?


Thanks!

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.