write.xport {SASxport} | R Documentation |
This function writes one or more data frames into a SAS XPORT format library file.
write.xport(..., list=base::list(), file = stop("'file' must be specified"), verbose=FALSE, sasVer="7.00", osType, cDate=Sys.time(), formats=NULL, autogen.formats=TRUE )
... |
One or more data frames to be stored |
list |
A list containing data frames to be stored. |
file |
File name or connection object. Use "" to view the raw data |
verbose |
Logical flag controlling whether status is reported during processing |
sasVer |
SAS version string |
osType |
Opererating system, defaults to "R X.Y.Z" for appropriate values of X, Y, and Z |
cDate |
Date object specifying dataset creation date |
formats |
Optional data frame containing SAS format information. |
autogen.formats |
Logical indiciating whether SAS formats should be auto-generated for factor variables. |
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.
In addition, the SAS XPORT format allows each variable to have a corresponding label, display format, and input format. To set these values, add the attribute 'label', 'SASformat', or 'SASiformat' to individual data frame variables. (See the example section.)
The actual translation of R objects to objects appropriate for SAS is
handled by the toSAS
generic and associated methods.
No return value
This package was created by Random Technologies LLC http://random-technologies-llc.com with partial funding by Metrum Institute http://metruminstitute.org.
Technical support contracts for this and other R packages are available from Random Technologies LLC http://random-technologies-llc.com.
Gregory R. Warnes greg@random-technologies-llc.com
SAS Technical Support document TS-140: ``The Record Layout of a Data Set in SAS Transport (XPORT) Format'' available at http://ftp.sas.com/techsup/download/technote/ts140.html.
toSAS
,
lookup.xport
,
read.xport
##### ## R version of the example given in TS-140 ##### ## manually create a data set temp <- data.frame( x=c(1, 2, NA, NA ), y=c('a', 'B', NA, '*' ) ) ## look at it temp ## add a format specifier (not used by R) attr(temp$x, 'SASformat') <- 'date7.' ## add a variable label (not used by R) attr(temp$y, 'label') <- 'character variable' ## verify the additions str(temp) ## rename the data set abc <- temp # create a SAS XPORT file write.xport( abc, file="xxx.dat" ) # list the contents of the file lookup.xport("xxx.dat") ## reload the data xxx.abc <- read.xport("xxx.dat") ## and look at it xxx.abc ## Note that the variable names have been converted to uppercase