Indirectly Load SAS Data into S-PLUS

DESCRIPTION:
Loads SAS data dumped by the SAS macro sas_get into S-PLUS.

USAGE:
sas.fget(base.name, var.file=paste(base.name,".1",sep=""),
     data.file=paste(base.name,".2",sep=""), id=<<see below>>,
     data.frame.out=T)

OPTIONAL ARGUMENTS:
base.name:
the base name of the data and variable files generated by the SAS macro. It is assumed that the data file will be base.name.2 and the variable description file will be base.name.1. If they don't follow this convention, you may supply their names directly with the var.file and data.file arguments.
var.file:
the name of the variable description file generated by the SAS macro.
data.file:
the name of the data file generated by the SAS macro.
id:
the name of the variable to be used as the row names of the S-PLUS dataset. (if data.frame.out is FALSE, this will be the attribute "id" of the S-PLUS dataset). If missing, the rows will be labeled by the counting numbers.
data.frame.out:
if TRUE, the output will be a data frame; if FALSE, a list.

VALUE:
if data.frame.out is TRUE, the output will be a data frame resembling the SAS dataset. If id was specified, that column of the data frame will be removed and used as the row names of the data frame.

If data.frame.out is FALSE, the output will be a list of vectors, each containing a variable from the SAS dataset. If id was specified, that element of the list will be used as the id attribute of the entire list.


DETAILS:
If S-PLUS and SAS can be run on the same computer, the sas.get function is a simpler way to import SAS data into S-PLUS.

Before using sas.fget you must copy the SAS macro stored in $SHOME/cmd/sas_get to the computer running SAS. If you are not familiar with running SAS macros, refer to the SAS documentation. Add three lines to the end of the copied macro: one line defines libnames for libraries containing data, one line defines the formats used in the data, and the third line calls the sas.get macro. For example, if your SAS object foo is stored in library SAS.data, formats are in the library SAS.formats, and you call your temporary files (to be read by sas.fget) file.1 and file.2, then the three lines to add are:

libname temp 'SAS.data'; libname library 'SAS.formats'; %sas_get(temp.foo, file.1, file.2, dates=sas, vars=, ifs=);

Once you have created the two files, copy them to the machine running S-PLUS. These are binary files, so be sure to copy them with a utility that leaves all the bits intact.

Finally, in S-PLUS, execute x <- sas.fget("file") to read the SAS data stored in the variable description file file.1 and the data file file.2.


REFERENCES:
SAS Institute Inc. (1990). SASO Language: Reference, Version 6. First Edition. SAS Institute Inc., Cary, North Carolina.

SAS Institute Inc. (1988). SASO Technical Report P-176, Using the SASO System, Release 6.03, under UNIXO O perating Systems and Derivatives. SAS Institute Inc., Cary, North Carolina.

SAS Institute Inc. (1985). SASO Introductory Guide. Third Edition. SAS Institute Inc., Cary, North Carolina.

The Getting Data Into and Out of S-PLUS chapter of the S-PLUS User's Manual.


SEE ALSO:
sas.get .