haven icon indicating copy to clipboard operation
haven copied to clipboard

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

Open sjkiss opened this issue 1 year ago • 0 comments

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

sjkiss avatar Jun 12 '24 18:06 sjkiss