Skip to content

Instantly share code, notes, and snippets.

@briatte

briatte/dta_to_sav.r

Created Feb 25, 2020
Embed
What would you like to do?
# package dependency
library(haven)
path_in = "new_EB with more var_2004-2016.dta"
out_tsv = "new_EB.tsv"
out_sav = "new_EB.sav"
# name repair shows the issue with _merge
x = haven::read_dta(p, .name_repair = "universal")
names(x)[ names(x) == "._merge" ] = "MERGEVAR"
haven::write_tsv(x, out_tsv) # TSV
haven::write_sav(x, out_sav) # SAV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.