tidyverse / haven

Read SPSS, Stata and SAS files from R
https://haven.tidyverse.org
Other
424 stars 117 forks source link

Haven splits a character string longer than 255 characters when exported as part of a data frame, does not when exported as a single variable #757

Open sjkiss opened 5 months ago

sjkiss commented 5 months ago

I have a dataset that has a string variable that has values up to 588 characters.

When I export the dataset to SAV, that variable is split at the 255 character limit. When I restrict the dataset to include only that variable, it does not.

I've tried my best to make a reproducible example. This will create two SAV files in a home path, sorry about that. I could really use some help to solve this.

library(haven)
library(tidyverse)
on18<-read_sav(file="https://github.com/sjkiss/Ontario_2018/raw/main/Data/Ontario%20ES%202018%20LISPOP.sav")
nchar(on18$indivfinfeel) %>% 
summary()
on18 %>% 
  write_sav(., path="~/test.sav")
on18 %>% 
  select(indivfinfeel) %>% 
  write_sav(., path="~/test2.sav")
Screenshot 2024-06-12 at 2 42 08 PM Screenshot 2024-06-12 at 2 41 59 PM