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 accessable using SASformat.SASiformat attributes on each
variable, and are accessable 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
Bug fixes:
write.xport() no longer sets an 8 character minumum length on string
variables.Other changes:
Other changes:
Bug fixes:
Now works properly on big-endian systems such as the PowerPC, Spark. (Reported by Brian Ripley )
Explicitly cast left bit shifts to avoid undefined C language behavior. (Reported by Brian Ripley)
Resolve problem in accessing "Hmisc::label.default<-" if SASxport::read.xport is called without loading SASxport. (Reported by Dominic Comtois)
'read.xport' now preserves '$' at the beginning of SAS character format and iformat strings. (Reported by Dominic Comtois)
'read.xport' argument names.tolower was not being honored for dataset names. (Reported by Dominic Comtois)
Other changes:
Modified several test files to display generated .xpt data so that issues can be more easily detected and diagnosed.
C code cleanup and reorgaization to improve clarity.
API Change:
Bug fixes:
Bug fixes:
Bug fixes:
Bug fixes:
Other Changes:
New features:
Bug fixes:
Integrate patch from foreign package to properly handle xport files with datasets that end exactly on an 80-byte record boundry & add corresponding test file.
Replace file.path(path.package(...)) with system.file(...)
Changes:
Remove oboslete .First.lib() function
Replace file.path(path.package(...)) with system.file(...)
Changes:
New features:
Bug fixes:
Bug fixes:
Bug fixes:
Bug fixes:
Other:
New Features:
SAS format and iformat information is now accessed via 'SASformat()' and 'SASiformat()' functions instead of 'formats' and 'iformat'. The information accessed by these functions is now stored in attributes with the same name. This avoids conflicts with the use of 'format' by chron objects.
Copies of the code for foreign::read.xport and foreign::lookup.xport is now part of the SASxport package, permitting extension to these functions as needed, and removing the dependency on the foreign package.
Overflow of SASxport numeric format values, which have a smaller range than IEEE 754 numeric values now standard, now generates NAN instead of 0.0.
Bug Fixes:
Fix for problem storing negative numbers.
SAS format length and digit information is now properly captured by read.xport(). This is supported by an improved version of lookup.xport().
SAS format information was not being properly utilized when more than one format was present.
Improved handling of SAS date formats
Other:
New Features:
Bug Fixes:
Other:
New Fetures:
Bug Fixes:
Other:
New features:
read.xport's names.tolower argument now defaults to FALSE so that variable (and data set) names are now left as uppercase.
Improved crediting of BRL-CAD source code
Bug fixes:
Other:
New Features:
Bug Fixes:
Changes to C code should correct the C99 usage errors
Correct documentation typos, including those reported by Tim.
Initial version of the SASxport package.