[R] How to read only ten rows from a SAS dataset (read.ssd)?
David Winsemius
dwinsemius at comcast.net
Tue Oct 19 15:54:20 CEST 2010
On Oct 19, 2010, at 6:47 AM, johannes rara wrote:
> I'm trying to read SAS datasets on Windows:
>
> sashome <- "C:/Program Files/SAS/SAS 9.1"
> fold <- "C:/temp"
> g <- read.ssd(fold, "sasfile", sascmd = file.path(sashome, "sas.exe"))
And this was successful?
>
> How to get only e.g first ten rows into R?
Presumably you also entered require(foreign) if you had success.
Looking at the help page, we see no parameter that would effect such a
result. So just type:
read.ssd
You see that this function's code is available and if you know SAS,
you should be able to insert the needed line that would limit the
dataset length to only ten lines. I'm not being coy. I would probably
had further suggestions 20 years ago when I was using SAS.
There is a function sas.get in package Hmisc that offers more
extensive control, but it is not clear to me on looking at the
parameters whether your particular request would be easily
accommodated. The ifs= parameter would appear to be the most promising
candidate to me. It appears that these file formats are accepted:
sasds.suffix <- c("sd2", "sd7", "ssd01", "ssd02", "ssd03",
"ssd04", "sas7bdat")
Also, since the use of read.ssd implies that you have a working copy
of SAS, then another option is simply exporting a file in the format
of your choice? The SAS XPT format seems to be well handled by
external programs.
--
David.
>
> -J
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list