[R] Re: Use of the Foreign package to import Stata files

Alan Cobo-Lewis alanc at umit.maine.edu
Mon Oct 6 21:38:19 CEST 2003


Long ago (Sat, 2 Nov 2002), Bill Hart <w.hart at sbcglobal.net> wrote: 
> An R newbie here. I am using R 1.6 currently and have 
> (successfully, I think) installed the Foreign package. 
> Tried to import a data file created with Stata 7.0 
> SE. Had minor problems with syntax then R decided 
> that my file was not really a Stata file. It rejected 
> the file saying 'Not created by Stata 5-7/SE'. Any 
> suggestions on how to convince R that this is really, 
> truly a Stata file? 
> 
Thomas Lumley (tlumley at u.washington.edu) responded:
> You need the version of read.dta that I wrote yesterday after finally 
> obtaining some 7/SE datasets for debugging. If you can compile packages 
> then I can send you the code, otherwise you will have to wait for the next 
> version of the foreign package. 

But sometimes older works better than newer. The read.dta() function in R 1.7.0's foreign package (package 0.6-3) fails to recognize as a Stata file what seems to be a genuine Stata file, even though R 1.6.2's foreign package (package 0.5-9) imports
the same file just work fine. Using R 1.7 and rolling the package back to foreign 0.5 doesn't seem to fix the problem (haven't been able to roll R1.7 all the way back to foreign 0.5-9 yet, just to a newer 0.5 whose binary is still posted on cran).

An example of such a Stata file it at
http://www.ats.ucla.edu/stat/stata/examples/rwg/concord1.dta

Does anyone have a hint or fix?

alan

--
Alan B. Cobo-Lewis, Ph.D.		(207) 581-3840 tel
Department of Psychology		(207) 581-6128 fax
University of Maine
Orono, ME 04469-5742     		alanc at maine.edu

http://www.umaine.edu/visualperception




More information about the R-help mailing list