Learn R Programming

repfun (version 0.1.2)

ru_data2codelist: Return a list with codelist, code and label based on input codelist dataset.

Description

Pass in a data set from a SAS format catalog (or similar) and have a list returned in the structure of a SAS format for decoding variables.

Usage

ru_data2codelist(
  dsetin,
  codelistvarname = "FMTNAME",
  codevarname = "START",
  decodevarname = "LABEL",
  typevarname = "TYPE"
)

Value

A list based on the incoming data frame but with decode values added along with records when completetypes is true.

Arguments

dsetin

Name of incoming data set structured as a SAS format catalog saved as a data set.

codelistvarname

Name of the variable containing the SAS format or similar.

codevarname

Name of the variable that holds the code value.

decodevarname

Name of the variable that holds the decode value.

typevarname

Type of format (character or numeric).

Examples

Run this code
library(repfun)
datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir")
dir.create(datdir,showWarnings=FALSE)
repfun::copydata(datdir)
rfenv <- repfun::rs_setup(R_RFMTDIR=datdir,RetEnv=TRUE)
list <- repfun::ru_data2codelist(rfenv$rfmtdata$formats.rda())
list$SEXS$START[[1]] # Code value 1
list$SEXS$LABEL[[1]] # Decode value 1
list$SEXS$START[[2]] # Code value 2
list$SEXS$LABEL[[2]] # Decode value 2

Run the code above in your browser using DataLab