read_all_xpt {EDCimport} | R Documentation |
Read all .xpt
files in a directory
Description
Read all .xpt
files in a directory (unzipped TrialMaster archive).
If 7zip
is installed, you should probably rather use read_trialmaster()
instead.
Formats (factors levels) can be applied from a procformat.sas
SAS file, or from a format dictionary. See the "Format file" section below. Column labels are read directly from the .xpt
files.
Usage
read_all_xpt(
path,
...,
format_file = "procformat.sas",
datetime_extraction = "guess",
subdirectories = FALSE,
verbose = getOption("edc_read_verbose", 1),
clean_names_fun = NULL,
directory = "deprecated",
key_columns = "deprecated"
)
Arguments
path |
[ |
... |
unused |
format_file |
[ |
datetime_extraction |
[ |
subdirectories |
[ |
verbose |
[ |
clean_names_fun |
|
directory |
deprecated in favor for |
key_columns |
deprecated |
Value
a list containing one dataframe for each .xpt
file in the folder, the extraction date (datetime_extraction
), and a summary of all imported tables (.lookup
).
Format file
format_file
should contain the information about SAS formats. It can be either:
a
procformat.sas
file, containing the whole PROC FORMATor a data file (
.csv
or.sas7bdat
) containing 3 columns:-
FMTNAME
the SAS format name (repeated) -
START
the variable level -
LABEL
the label associated to the level
You can get this datafile from SAS using
PROC FORMAT
with optionCNTLOUT
. Otherwise, you can useoptions(edc_var_format_name="xxx", edc_var_level="xxx", edc_var_label="xxx")
to specify different column names.-
See Also
Other EDCimport reading functions:
read_all_csv()
,
read_all_sas()
,
read_trialmaster()
Examples
# Create a directory with multiple .xpt files.
path = paste0(tempdir(), "/read_all_xpt")
dir.create(paste0(path, "/subdir"), recursive=TRUE)
haven::write_xpt(attenu, paste0(path, "/attenu.xpt"))
haven::write_xpt(mtcars, paste0(path, "/mtcars.xpt"))
haven::write_xpt(mtcars, paste0(path, "/subdir/mtcars.xpt"))
haven::write_xpt(esoph, paste0(path, "/esoph.xpt"))
db = read_all_xpt(path, format_file=NULL, subdirectories=TRUE) %>%
set_project_name("My great project")
db
edc_lookup()