`write_spss` Error: SPSS only supports levels with <= 120 characters
b1azk0 opened this issue · comments
Hello there,
I can't find a way around an issue where string variables imported from SPSS via
df <- read_spss(path = "fin.sav", verbose = F, atomic.to.fac = F)
get exported out as strings back to SPSS file using:
write_spss(df, "df.sav")
Even thou I don't touch string variables while cleaning data in R, there is always this problem:
$ Q56.0 <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…
$ MTurk_Code <chr> "2178656", "466017", "4774295", "2489282", "8603893", "7867333", "3413926", "6734111", "7472350", "…
$ batch <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…
$ CyberCond <chr> "", "", "", "", "Exclusion", "", "", "", "", "", "", "", "", "Inclusion", "", "", "Exclusion", "", …
$ VAR00001 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, …
> write_spss(df, "df.sav")
Tidying value labels. Please wait...
Writing spss file to 'df.sav'. Please wait...
Error: SPSS only supports levels with <= 120 characters
Problems: `name`, `Q57`, `Q56.0`
The only way around I know of is using haven::write_sav()
but then I loose all labels.
I think this issue is related to the haven-package (try to reproduce this error with haven::write_spss()
or the ReadStat library that is used by haven.
Have you checked if this is related to the haven package?
bump
Hi, sorry, I haven't tried. I started removing those kind of variables from my dataset and no longer keep them in SPSS format.