Skip to contents

Writes a local data frame into SAS transport file of version 5. The SAS transport format is an open format, as is required for submission of the data to the FDA.

Usage

xportr_write(.df, path, label = NULL, strict_checks = FALSE)

Arguments

.df

A data frame to write.

path

Path where transport file will be written. File name sans will be used as xpt name.

label

Dataset label. It must be <=40 characters.

strict_checks

If TRUE, xpt validation will report errors and not write out the dataset. If FALSE, xpt validation will report warnings and continue with writing out the dataset. Defaults to FALSE

Value

A data frame. xportr_write() returns the input data invisibly.

Details

  • Variable and dataset labels are stored in the "label" attribute.

  • SAS length are stored in the "SASlength" attribute.

  • SAS format are stored in the "SASformat" attribute.

  • SAS type are stored in the "SAStype" attribute.

Examples

adsl <- data.frame(
  Subj = as.character(123, 456, 789),
  Different = c("a", "b", "c"),
  Val = c("1", "2", "3"),
  Param = c("param1", "param2", "param3")
)

xportr_write(adsl,
  path = paste0(tempdir(), "/adsl.xpt"),
  label = "Subject-Level Analysis",
  strict_checks = FALSE
)
#> Warning: The following validation checks failed:
#>  Variable `Different` must be 8 characters or less.
#>  Variables `Subj`, `Different`, `Val`, and `Param` cannot contain any lowercase characters.