Closed
Description
openedon Dec 9, 2022
It seems that NA_character_
is handled as a string of length 2 when writing a SAS transport file with write_xpt()
. Consider for example:
t <- data.frame(MYFL = c("Y", NA_character_), id = c(1, 2))
attr(t[["MYFL"]], "width") <- 1
haven::write_xpt(t, "t.xpt", version = 5, name = "t")
It produces
Warning message:
Column `MYFL` contains string values longer than user width 1. Width set to 2 to accommodate.
and the length of MYFL
in the SAS transport file is 2.
Is this intended?
I would expect length 1 and no warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment