简体   繁体   中英

not a Stata version 5-12 .dta file

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.

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.

What I want to add about the read_dta is that first you have to install haven, eg

#set working directory 
install.packages("haven")
library(haven)
data <- read_dta ("data.dta")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM