Learn R Programming

haven (version 2.1.1)

read_sas: Read and write SAS files.

Description

read_sas() supports both sas7bdat files and the accompanying sas7bcat files that SAS uses to record value labels. write_sas() is currently experimental and only works for limited datasets.

Usage

read_sas(data_file, catalog_file = NULL, encoding = NULL,
  catalog_encoding = encoding, cols_only = NULL)

write_sas(data, path)

Arguments

data_file, catalog_file

Path to data and catalog files. The files are processed with readr::datasource().

encoding, catalog_encoding

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.

cols_only

A character vector giving an experimental way to read in only specified columns.

data

Data frame to write.

path

Path to file where the data will be written.

Value

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.

Examples

Run this code
# NOT RUN {
path <- system.file("examples", "iris.sas7bdat", package = "haven")
read_sas(path)
# }

Run the code above in your browser using DataLab