Reads an XPT transport file and writes it as CDISC Dataset-JSON v1.1.
All metadata (labels, formats, lengths) is preserved.
Usage
xpt_to_json(xpt_path, json_path, dataset = NULL, label = NULL)
Arguments
- xpt_path
Path to a .xpt file.
- json_path
Output path for the .json file.
- dataset
Dataset name override. Default: inferred from file name.
- label
Dataset label override. Default: from XPT header.
Value
The output path, invisibly.
Examples
dm <- data.frame(STUDYID = "S1", AGE = 65L, stringsAsFactors = FALSE)
xpt <- tempfile(fileext = ".xpt")
json <- tempfile(fileext = ".json")
write_xpt(dm, xpt, dataset = "DM", label = "Demographics")
xpt_to_json(xpt, json)
read_json(json)
#> STUDYID AGE
#> 1 S1 65
unlink(c(xpt, json))