Functions for reading, listing the contents of, and writing 'SAS' 'xport' format files. The functions support reading and writing of either individual data frames or sets of data frames. Further, a mechanism has been provided for customizing how variables of different data types are stored.
This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either individual data frames or sets of data frames. Further, a mechanism has been provided for customizing how variables of different data types are stored.
install.packages("SASxport")
devtools::install_github("warnes/SASxport")
library(SASxport)
write.xport writes one or more data frames into a SAS XPORT format
library file.
The function creates a SAS XPORT data file (see reference) from one or more data frames. This file format imposes a number of constraints:
autogen.formats = TRUE (the default), factor variables are
stored as numeric with an appropriate SAS format
specification. If autogen.formats = FALSE, factor variables
are stored as characters..The SAS XPORT format allows each dataset to have a label and a
type (set via the label and SAStype functions). In addition,
each variable may have a corresponding label, display format, and
input format. To set these values, add the attribute label,
SASformat, or SASiformat to individual data frame. These
attributes may be set using the label, SASformat, and
SASiformat functions. (See examples in the package.)
The actual translation of R objects to objects appropriate for SAS
is handled by the toSAS generic and associated methods, which
can be (re)defined by the user to provide fine-grained control.
read.xport reads a file as a SAS XPORT format library and returns a list
of data frames:
Date, POSIX, or chron objects.label attributes on each variable,
and are accessible using the label function.SASformat attributes on each
variable, and are accessible using SASformat.SASiformat attributes on each
variable, and are accessible using SASiformat.force.integer is FALSE.If the file includes the output of PROC FORMAT CNTLOUT=,
variables having customized label formats will be converted to
factor objects with appropriate labels.
If a datasets in the original file has a label or type, these will
be stored in the corresponding label and SAStype attributes,
which can be accessed by the label and SAStype functions.
GPL 2.1 © Gregory R. Warnes, United States Government, Frank E. Harrell, Jr., Douglas M. Bates, Mango Solutions