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.
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.
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.
The current version is Stata 17, released in April 2021.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With