Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

not a Stata version 5-12 .dta file

Tags:

r

I am trying to use existed data in my pc which is .dta file.

I'm trying to open it in R using the following command:

mydata<-read.dta(file="C:\\Users\\me\\Desktop\\data_raw.dta")

But there is this error

>> not a Stata version 5-12 .dta file 

Any help will be appreciated. Thanks.

like image 885
SBA Avatar asked Aug 29 '18 10:08

SBA


People also ask

Is .DTA a Stata file?

Stata data files have . dta extensions. See the “How to Import an Excel or Text Data File into Stata” handout for information on how to import other types of data files into Stata.

What is the file extension for Stata?

The Stata_dta format (with extension . dta) is a proprietary binary format designed for use as the native format for datasets with Stata, a system for statistics and data analysis.

Is from a more recent version of Stata?

The current version is Stata 17, released in April 2021.


1 Answers

Had the same problem and Roland's suggestion of using read_dta from the haven package worked!

To reiterate Roland's comment that helped form this solution. read.dta from the foreign package can only read files from Stata version 5 to 12 and your file seems to be created by a version outside that range.

haven's read_dta can read dta files outside of this range.

like image 179
Weevils Avatar answered Oct 03 '22 13:10

Weevils