Convert a SAS Dataset to a S-PLUS Dataset

DESCRIPTION:

Converts a SAS dataset into a S-PLUS data frame. This function is deprecated; please use instead.

You may choose to extract only a subset of variables or a subset of observations in the SAS dataset.

Note: This function is deprecated. For more information, see .

USAGE:

sas.get(library, member, variables=<<see below>>, ifs=<<see below>>, 
     format.library=library, id=<<see below>>, dates="sas", keep.log=T, 
     log.file="_temp_.log", macro="sas_get", macro.dir=<<see below>>, 
     data.frame.out=T, clean.up=T, quiet=F, temp=tempfile("SaS")) 

REQUIRED ARGUMENTS:

library
character string naming the directory in which the dataset is kept.
member
character string giving the second part of the two part SAS dataset name. (The first part is irrelevant here - it is mapped to the UNIX directory name.)

OPTIONAL ARGUMENTS:

variables
vector of character strings naming the variables in the SAS dataset. The S-PLUS dataset will contain only those variables from the SAS dataset. To get all of the variables (the default), an empty string may be given. It is a fatal error if any one of the variables is not in the SAS dataset. You can use sas.contents to get the variables in the SAS dataset.
ifs
a vector of character strings, each containing one SAS "subsetting if" statement. These will be used to extract a subset of the observations in the SAS dataset.
format.library
The UNIX directory containing the file formats.sct, which contains the definitions of the user defined formats used in this dataset. By default, we look for the formats in the same directory as the data. N.B. The user defined formats must be available (so SAS can read the data), but they are not used by this version of sas.get.
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.) By default, all variables are left in.
dates
One of the character strings "sas", "yearfrac", "yearfrac2", "yymmdd". If a SAS variable has a date format (one of "DATE", "MMDDYY", "YYMMDD", "DDMMYY", "YYQ", "MONYY", "JULIAN"), it will be converted to the format specified by dates before being given to S-PLUS. "sas" gives days from 1/1/1960, "yearfrac" gives days from 1/1/1900 divided by 365.25, "yearfrac2" gives year plus fraction of current year, and "yymmdd" gives a 6 digit number YYMMDD (year%%100, month, day). Note that S-PLUS will store these as double precision numbers, not as character strings.
keep.log
logical flag: if FALSE, delete the SAS log file upon completion.
log.file
the name of the SAS log file.
macro
the SAS macro called by S-PLUS. You may want to fiddle with this if you know what you are doing.
macro.dir
the directory in which the SAS macro is kept. By default it is $SHOME/cmd.
data.frame.out
logical flag: if TRUE, the return value will be a S-PLUS data frame, otherwise it will be a list.
clean.up
logical flag: if TRUE, remove all temporary files when finished. You may want to keep these while debugging the SAS macro.
quiet
logical flag: if FALSE, show the contents of the SAS log file if there has been an error. The log file is displayed under control of the program named in S-PLUS option pager.
temp
the prefix to use for the temporary files. Two characters will be added to this, the resulting name must fit on your file system.

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.

SIDE EFFECTS:

if a SAS error occurs and quiet is FALSE, then the SAS log file will be displayed under the control of the program named in S-PLUS option pager.

NOTE:

You must be able to run SAS (by typing sas from the Bourne shell) on your system. If the S-PLUS command unix("sas", out=F) does not start SAS, then this function cannot work. In particular, sas should not be a csh alias: the directory containing the sas command should be in your PATH environmental variable.

BACKGROUND:

The references cited below explain the structure of SAS datasets and how they are stored under UNIX. See SAS\u\s-1\(rg\s+1\d Language for a discussion of the "subsetting if" statement.

REFERENCES:

SAS Institute Inc. (1990). SAS\u\s-1\(rg\s+1\d Language: Reference, Version 6. First Edition. SAS Institute Inc., Cary, North Carolina.

SAS Institute Inc. (1988). SAS\u\s-1\(rg\s+1\d Technical Report P-176, Using the SAS\u\s-1\(rg\s+1\d System, Release 6.03, under UNIX\u\s-1\(rg\s+1\d Operating Systems and Derivatives. SAS Institute Inc., Cary, North Carolina.

SAS Institute Inc. (1985). SAS\u\s-1\(rg\s+1\d Introductory Guide. Third Edition. SAS Institute Inc., Cary, North Carolina.

SEE ALSO:

, , , .

EXAMPLES:

sas.contents("saslib", "mice") 
[1] "dose  "  "ld50  "  "strain"  "lab_no" 
attr(, "n"): 
[1] 117 
mice <- sas.get("saslib", mem="mice", var=c("dose", "strain", "ld50")) 
plot(mice$dose, mice$ld50) 
nude.mice <- sas.get(lib=unix("echo $HOME/saslib"), mem="mice", 
        ifs="if strain='nude'") 
nude.mice.dl <- sas.get(lib=unix("echo $HOME/saslib"), mem="mice", 
        var=c("dose", "ld50"), ifs="if strain='nude'")