List the Variables in a SAS Dataset

DESCRIPTION:
Returns a vector of the variable names in a SAS dataset, along with the number of observations in the dataset.

USAGE:
sas.contents(library, member, keep.log=T, log.file="_temp_.log",
     macro="sas_vars", macro.dir=<<see below>>, clean.up=T,
     quiet=F, temp=tempfile("SaS"))

REQUIRED ARGUMENTS:
library:
character string naiming the directory in which the 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.) This should never contain more than one name.

OPTIONAL ARGUMENTS:
keep.log:
logical flag: if FALSE, we delete the SAS log file after extracting the information from SAS.
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.
clean.up:
logical flag: if TRUE, all temporary files are removed upon finishing. You may want to keep these while debugging the SAS macro.
quiet:
logical flag: if FALSE, print the contents of the SAS log file if there has been an error.
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:
A character vector of the variable names. The attribute "n" will be the number of observations in the dataset.

SIDE EFFECTS:
if a SAS error occurs and quiet is FALSE, then the SAS log file will be printed under the control of the less 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.

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

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


SEE ALSO:
sas.get , sas.datasets .

EXAMPLES:
  sas.contents("saslib", "mice")

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