Reputation: 299
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:
library(foreign)
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.
Upvotes: 20
Views: 28255
Reputation: 61
What I want to add about the read_dta is that first you have to install haven, e.g.
install.packages("haven")
library(haven)
data <- read_dta("data.dta")
Upvotes: 6
Reputation: 366
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.
Upvotes: 19