Skip to content

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

@sjkiss

Description

@sjkiss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorreadstatrequires updates to ReadStat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions