SASxport (version 1.7.0)

SASxport-package: Read and Write SAS Export Files


This package provides functions to read, list contents of, and write SAS export files.



lookup.xport            Lookup Information on a SAS XPORT Format
read.xport              Import SAS XPORT files
toSAS.default           Convert R data object for storage in SAS
                        xport file
units                   Set or Retrieve the label, SASformat,
                        SASiformat, or units Attribute of a Vector
write.xport             Write data to a SAS XPORT file
makeSASNames            Create valid SAS names from a character vector.


This creation of this package was partially funded by Metrum Institute


Gregory R. Warnes


The read.xport function reads SAS xport formatted files, augmenting the functionality of the read.xport function provided in the 'foreign' package with additional features, borrowed from sasxport.get in Frank Harrell's 'Hmisc' package. Namely, variables are properly coerced into the types specified by the format field. All standard numeric and string SAS formats are supported automatically, while user-defined formats are supported when the user has included the appropriate format data in the xport file via:


In addition, labels are supported for variable and data frames, as are dataset 'types'.

The write.xport function writes one or more data sets into a SAS xport formatted file. Standard R data types, including date and time objects (e.g. Date, and POSIX.t) are stored with proper SAS format types. Handling of object formatting is customizable by providing methods for the function toSAS. This is accomplished by writing a new method for toSAS for the object class of interest. The toSAS method is responsible for converting its argument to either a simple floating point or character variable (the only basic types permitted by the xport format) and adding the appropriate SAS format code in the "SASformat" attribute.

The write.xport function also allows the user to override the operating system type and SAS version information, as well as object creation and modification times.