read_sas()
supports both sas7bdat files and the accompanying sas7bcat files
that SAS uses to record value labels.
read_sas(
data_file,
catalog_file = NULL,
encoding = NULL,
catalog_encoding = encoding,
col_select = NULL,
skip = 0L,
n_max = Inf,
cols_only = deprecated(),
.name_repair = "unique"
)
A tibble, data frame variant with nice defaults.
Variable labels are stored in the "label" attribute of each variable. It is not printed on the console, but the RStudio viewer will show it.
write_sas()
returns the input data
invisibly.
Path to data and catalog files. The files are
processed with readr::datasource()
.
The character encoding used for the
data_file
and catalog_encoding
respectively. A value of NULL
uses the
encoding specified in the file; use this argument to override it if it is
incorrect.
One or more selection expressions, like in
dplyr::select()
. Use c()
or list()
to use more than one expression.
See ?dplyr::select
for details on available selection options. Only the
specified columns will be read from data_file
.
Number of lines to skip before reading data.
Maximum number of lines to read.
Treatment of problematic column names:
"minimal"
: No name repair or checks, beyond basic existence,
"unique"
: Make sure names are unique and not empty,
"check_unique"
: (default value), no name repair, but check they are
unique
,
"universal"
: Make the names unique
and syntactic
a function: apply custom name repair (e.g., .name_repair = make.names
for names in the style of base R).
A purrr-style anonymous function, see rlang::as_function()
This argument is passed on as repair
to vctrs::vec_as_names()
.
See there for more details on these terms and the strategies used
to enforce them.
path <- system.file("examples", "iris.sas7bdat", package = "haven")
read_sas(path)
Run the code above in your browser using DataLab