Public service announcement for other SuSo users who work between R and Stata, use SuSo’s Stata files, and ingest them with
In the period January 13, 2020 and prior, I used the following in injest SuSo’s Stata data into R:
library(haven) someFolder <- "C:/my/folder/" someFile <- "some_file.dta" myData <- haven::read_stata(paste0(someFolder, someFile), encoding = "UTF-8")
On January 14, I tried the same with newly generated data, and got an error message of this form:
Error in df_parse_dta_file(spec, encoding, cols_skip, n_max, skip, name_repair = .name_repair) : Failed to parse C:/my/folder/some_file.dta: Unable to convert string to the requested encoding (invalid byte sequence).
Looking at the
haven documentation, I realized that I didn’t need to specify encoding. See discussion of encoding here. When I removed the encoding specification, everything worked fine.
myData <- haven::read_stata(paste0(someFolder, someFile))
I’m not sure what changed. The
haven package hasn’t been updated since November 2019. The export files I worked with on Jan 13 were generated by SuSo 20.01.0.1320. The export files I worked with on Jan 14 were from the same server, but I’ll have to update later on the SuSo version that generated them.