Learn R Programming

ksformat (version 0.3.5)

fimport: Import Formats from 'SAS' PROC FORMAT CNTLOUT CSV

Description

Reads a CSV file produced by 'SAS' PROC FORMAT with CNTLOUT= option (typically exported via PROC EXPORT) and converts compatible format definitions into ks_format and ks_invalue objects.

Usage

fimport(file, register = TRUE, overwrite = TRUE)

Value

A named list of ks_format and ks_invalue objects that were successfully imported. Returned invisibly.

Arguments

file

Path to the CSV file exported from a SAS format catalogue.

register

Logical; if TRUE (default), each imported format is registered in the global format library.

overwrite

Logical; if TRUE (default), existing library entries with the same name are overwritten.

Details

The 'SAS' format catalogue CSV is expected to contain the standard CNTLOUT columns: FMTNAME, START, END, LABEL, TYPE, HLO, SEXCL, EEXCL.

Supported SAS format types:

N

Numeric VALUE format \(\to\) ks_format with type = "numeric"

C

Character VALUE format \(\to\) ks_format with type = "character"

I

Numeric INVALUE (informat) \(\to\) ks_invalue with target_type = "numeric"

J

Character INVALUE (informat) \(\to\) ks_invalue with target_type = "character"

Incompatible types (logged with a warning):

P

PICTURE formats \(-\) no equivalent in ksformat

Rows with SAS special missing values (.A\(-\).Z, ._) in the HLO field are logged as incompatible entries and skipped because R has no equivalent concept.

Examples

Run this code
# In SAS:
# proc format library=work cntlout=fmts; run;
# proc export data=fmts outfile="formats.csv" dbms=csv replace; run;

csv_file <- system.file("extdata", "test_cntlout.csv", package = "ksformat")
imported <- fimport(csv_file)
fprint()
fclear()

Run the code above in your browser using DataLab