Skip to content

read_xpt does not properly read SAS xport file with multiple members #795

Description

@sasutils

The read_xpt() function cannot properly handle a SAS transport file (XPORT format) that contains multiple SAS datasets. Instead of reading all of them into separate data frames (or tibbles) the way that read.xport() does it mistakenly reads the entire file as part of the first dataset, generating gibberish observations.

The v5.xpt file in this ZIP file has two datasets, MISSING and CLASS.
v5.xpt.zip

x <- "~/Documents/Rprojects/v5.xpt"
library(foreign)
y <- read.xport(x)
library(haven)
z <- read_xpt(x)

The read.xport() function from foreign properly reads the two datasets making y$MISSING as a data frame with 2 variables and 31 observations. And y$CLASS as a data frame with 5 variable and 19 observation.

But the read_xpt() function makes a single tibble with two variables and 239 observations. The first 31 are fine, but the rest are gibberish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions