Learn R Programming

mariposa (version 0.7.3)

read_xpt: Read SAS Transport File with Tagged Missing Values

Description

Reads a SAS transport file (.xpt) and integrates with mariposa's tagged NA system. Handles both native SAS special missing values and user-specified numeric missing codes (via tag_na). Transport files are a platform-independent SAS data format commonly used for FDA submissions and data exchange.

Usage

read_xpt(path, tag_na = NULL, verbose = FALSE)

Value

A tibble with the SAS data. See read_sas() for details on tagged NA handling.

Arguments

path

Path to a SAS transport file (.xpt).

tag_na

Numeric vector of values to treat as missing (e.g., c(-9, -8, -42)). These values will be converted to tagged NAs across all numeric variables. Default: NULL (only detect native SAS special missing values).

verbose

If TRUE, prints a message summarizing how many variables contain tagged missing values.

Details

SAS transport files support the same special missing values as .sas7bdat files (.A-.Z, ._). This format is self-contained and does not require a separate catalog file for value labels.

When tag_na is used, untag_na() can recover the original numeric codes.

See Also

read_sas(), na_frequencies(), strip_tags(), untag_na(), haven::read_xpt()

Other data-import: na_frequencies(), read_por(), read_sas(), read_spss(), read_stata(), read_xlsx(), strip_tags(), untag_na()

Examples

Run this code
# \donttest{
if (requireNamespace("haven", quietly = TRUE)) {
  # Roundtrip through a temporary .xpt transport file
  tmp <- tempfile(fileext = ".xpt")
  write_xpt(survey_data, tmp)
  data <- read_xpt(tmp)

  # Read with numeric missing codes tagged as distinct NA types
  data <- read_xpt(tmp, tag_na = c(-9, -8))

  unlink(tmp)
}
# }

Run the code above in your browser using DataLab