Skip to content

write_xpt ignores top level label attribute (but read_xpt honors it) #562

@bergsmat

Description

@bergsmat

The specification for SAS Transport (https://support.sas.com/techsup/technote/ts140.pdf) provides that each dataset may have a label, not to be confused with column labels. haven::read_xpt() honors these where they exist, but write_xpt() does not (at least, does not react to attribute 'label' and apparently does not support alternative mechanism of supplying same). 'label' is not to be confused with 'name' which is supported (but cannot contain spaces ... consider adding that to documentation). I have not tried CRAN version 2.3.1 but there are no changes in documentation. I'd like to see data.frame 'label' written by write_xpt() to wherever read_xpt() is retrieving it.

library(SASxport) # 1.6.0
library(haven)    # 2.1.0
library(magrittr)
label(mtcars) <- 'My Cars'
mtcars %>% write.xport(file = 'SASxp.xpt') 
mtcars %>% write_xpt('haven.xpt') 
'SASxp.xpt' %>% read.xport %>% attributes %$% label # "My Cars"
'haven.xpt' %>% read.xport                          # no SAS header! (different problem)
'SASxp.xpt' %>% read_xpt   %>% attributes %$% label # "My Cars"
'haven.xpt' %>% read_xpt   %>% attributes %>% names # no label 

Metadata

Metadata

Assignees

No one assigned

    Labels

    reprexneeds a minimal reproducible example

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions