read_ssocs: Read SAS file and value labels according to PROC FORMAT

Description Usage Arguments Value See Also Examples

View source: R/read_ssocs.R

Description

Reads a SAS 'sas7bdat' file using [haven::read_sas] and then applies the labels given in the formats file (containing 'PROC FORMAT' statements). The labels use [labelled::labelled] and may be coerced to factors or ordered factors if desired.

Usage

1
2
3
4
5
6
7
read_ssocs(
  datafile,
  formatfile,
  fmtfile = NULL,
  as_factor = TRUE,
  ordered = TRUE
)

Arguments

datafile

Path to the 'sas7bdat' file to be read by [haven::read_sas]

formatfile

Path to the SAS formats file to be read by [read_proc_format]

fmtfile

Path to the SAS fmts file to be read by [read_proc_format_vars]

as_factor

If TRUE, coerce labelled variables to factor with [haven::as_factor]

ordered

If TRUE and as_factor is TRUE, coerce to ordered factor

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.

The vectors may be a labelled vector that may be coerced into a factor or ordered factor.

See Also

Other SAS helper functions: read_proc_format_vars(), read_proc_format()

Examples

1
2
3
4
## Not run: 
read_ssocs("pu_ssocs18.sas7bdat", "pu_ssocs18_format.txt")

## End(Not run)

haleyjeppson/sastools documentation built on Dec. 20, 2021, 2:46 p.m.