xpt_members: List the members of a SAS XPORT transport file

View source: R/codec_xpt.R

xpt_membersR Documentation

List the members of a SAS XPORT transport file

Description

Report every dataset (member) a SAS Transport (.xpt) file holds, with its label, variable count, and row count — the survey step before read_xpt() with ⁠member =⁠ picks one. A single-member file (the FDA submission convention) returns one row.

Usage

xpt_members(path)

Arguments

path

Source .xpt path. ⁠<character(1)>: required⁠. A file that is not a valid XPORT library aborts with artoo_error_codec.

Details

v5 has no recorded row count. A v8 member records its rows; a v5 member's count is derived from the byte span up to the next member (or end of file) minus trailing padding, so an all-character v5 member whose last row is entirely blank reports one row fewer (the documented v5 ambiguity, see write_xpt()).

Value

A ⁠<data.frame>⁠ with one row per member and columns member (1-based index), name, label, nvars, and nobs. Pass member or name to read_xpt().

See Also

read_xpt() with ⁠member =⁠ to read one of them.

Examples

spec <- artoo_spec(
  cdisc_adam_datasets, cdisc_adam_variables,
  codelists = cdisc_codelists
)

# ---- Example 1: a single-member file reports one row ----
#
# The FDA convention is one dataset per transport file.
dm <- apply_spec(cdisc_dm, sdtm_spec, "DM", conformance = "off")
p <- tempfile(fileext = ".xpt")
write_xpt(dm, p)
xpt_members(p)

# ---- Example 2: survey a multi-member file, then read one member ----
#
# Concatenate two single-member files into one library and list it.
adsl <- apply_spec(cdisc_adsl, spec, "ADSL", conformance = "off")
p2 <- tempfile(fileext = ".xpt")
write_xpt(adsl, p2)
multi <- tempfile(fileext = ".xpt")
writeBin(
  c(
    readBin(p, "raw", file.size(p)),
    readBin(p2, "raw", file.size(p2))[-(1:240)]
  ),
  multi
)
xpt_members(multi)


artoo documentation built on July 23, 2026, 1:08 a.m.