write.xport {SASxport}R Documentation

Write Data to a SAS XPORT File

Description

This function writes one or more data frames into a SAS XPORT format library file.

Usage

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
 )

Arguments

... 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.

Details

The function creates a SAS XPORT data file (see reference) from one or more data frames. This file format imposes a number of constraints:

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.

Value

No return value

Note

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.

Author(s)

Gregory R. Warnes greg@random-technologies-llc.com

References

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.

See Also

toSAS, lookup.xport, read.xport

Examples


#####
## 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


[Package SASxport version 1.2.2 Index]