Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in df_parse_dta_file(): Failed to parse C:/Users/folder/data.dta: This version of the file format is not supported

I wanted to read in a .dta file in R in order to convert it to a .csv file. First, I tried to do so by using the foreign package, but it reported:

Error in read.dta(file): not a Stata version 5-12 .dta file

So I tried to do it by using teh haven package, but that also failed and reported:

Error in df_parse_dta_file(spec, encoding, cols_skip, n_max, skip, name_repair = .name_repair) : Failed to parse C:/Users/folder/data.dta: This version of the file format is not supported

I also tried to convert it with the rio package: install.packages("rio") library(rio) install_formats() convert("file.dta","file.csv")

but it reported:

Error in arg_reconcile(haven::read_dta, file = file, ..., .docall = TRUE, : Failed to parse C:/Users/folder/data.dta: This version of the file format is not supported. This error was generated by: haven::read_dta With the following arguments: "._costs.dta"

Does anyone know how to import such .dta files in R so that one can convert a .csv file ?

PS: The preamble of the .dta-file looks like this:

<stata_dta>118LSFM 23 Apr 2019 16:22

like image 321
stats19 Avatar asked Nov 20 '25 06:11

stats19


1 Answers

Try adding encoding = "UTF-8" or encoding = "Latin1" inside the read_dta() function to tell R import same data without encoding into numbers. It might take a little while to clean data tho :(

like image 167
Trace Ashley Avatar answered Nov 22 '25 23:11

Trace Ashley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!