Obtain a Data Frame from a SAS Permanent Dataset, via read.xport
Generates a SAS program to convert the ssd contents to SAS transport format
and then uses
read.xport to obtain a data frame.
read.ssd(libname, sectionnames, tmpXport=tempfile(), tmpProgLoc=tempfile(), sascmd="sas")
- character string defining the SAS library (usually a directory reference)
- character vector giving member names. These are
files in the
libnamedirectory. They will usually have a
.sas7bdatextension, which should be omitted. Use of ASCII names of at most 8 characters is strongly recommended.
- character string: location where temporary xport format archive should reside -- defaults to a randomly named file in the session temporary directory, which will be removed.
- character string: location where temporary conversion SAS program should reside -- defaults to a randomly named file in session temporary directory, which will be removed on successful operation.
- character string giving full path to SAS executable.
Creates a SAS program and runs it.
Error handling is primitive.
A data frame if all goes well, or
NULLwith warnings and some enduring side effects (log file for auditing)
This requires SAS to be available. If you have a SAS dataset
without access to SAS you will need another product to convert it to a
format such as
.csv, for example Stat/Transfer or
DBMS/Copy or the SAS System Viewer (Windows only).
SAS requires section names to be no more than 8 characters. This is worked by the use of symbolic links: these are barely supported on Windows.
## if there were some files on the web we could get a real ## runnable example ## Not run: # R> list.files("trialdata") #  "baseline.sas7bdat" "form11.sas7bdat" "form12.sas7bdat" #  "form13.sas7bdat" "form22.sas7bdat" "form23.sas7bdat" #  "form3.sas7bdat" "form4.sas7bdat" "form48.sas7bdat" #  "form50.sas7bdat" "form51.sas7bdat" "form71.sas7bdat" #  "form72.sas7bdat" "form8.sas7bdat" "form9.sas7bdat" #  "form90.sas7bdat" "form91.sas7bdat" # R> baseline <- read.ssd("trialdata", "baseline") # R> form90 <- read.ssd("trialdata", "form90") # # ## Or for a Windows example # sashome <- "/Program Files/SAS/SAS 9.1" # read.ssd(file.path(sashome, "core", "sashelp"), "retail", # sascmd = file.path(sashome, "sas.exe")) # ## End(Not run)