On Fri, 27 Aug 2004, Sundar Dorai-Raj wrote:
>
> S�ren H�jsgaard wrote:
>
> > Dear all,
> > One of my students (whom I am trying to convince to use R) wants to get a fairly
> > large SAS dataset into R (about 150mB). An obvious and simple thing she tried was
> > to write the dataset as a .csv-file and then read that into R, but that takes
> > forever (or something close to that..). The dataset is so large, that exporting it
> > as an Excel file from SAS is not feasible (more than 65000 lines). I am reluctant
> > to ask her to go through all the data base steps (then she'll just stick to
> > SAS...). Can anyone help me out on that one?
> > Thanks in advance
> > S�ren H�jsgaard
> >
> >
>
> See ?read.ssd in package:foreign or ?sas.get in package:Hmisc. Both
> require you have SAS installed and in your PATH.
Those routines use the SAS XPORT procedure, which is a good
semi-non-proprietary way to save your data anyway. I just fought with
this a long while and found that XPORT needs to write short variable
names, but cannot accept the longer table names. The short stub of SAS I
needed was:
Given a sas file '/junk/data.sas7bdat' files, the short stub of SAS code should
extract the data to '/junk/rd.xport' (The paths here may be all messed
up, but maybe the options below will save you the hours I lost.)
libname src2rd '/junk/data'
libname rd xport '/junk/rd'
proc copy in=src2rd out=rd;
select data;
However it may fail if there are long variable names. The SAS below works
around that:
options VALIDVARNAME=V7; /* enable longnames of {V6|V7|UPCASE|ANY} */
data shrtnm;
set verylonggtablename;
run;
However, when longnames are enabled, the XPORT procedure fails on long
variable names, so the option must be set to truncate the long variable
names into shortnames:
options VALIDVARNAME=V6; /* enable xport varname truncation */
proc copy in=work out=rd1 memtype=data;
select shrtnm ;
run;
Once this is done, the data may be imported into R using read.xport
Library(foreign) :
x<-read.xport("/junk/x.xport")
R is sooo much better than SAS.
Dave
--
Dave Forrest
[EMAIL PROTECTED] (804)684-7900w
[EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/
______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html