[R] Reading SAS version 8 data into R

Bill Oliver wloliver at qwest.net
Fri Aug 24 01:21:34 CEST 2001


----- Original Message -----
From: "Søren Højsgaard" <sorenh at mail.dk>


> Hi,
>
> SAS transport files created with the xport engine in SAS can be read using
read.xport.  However, the xport engine only works with SAS version 6, and
consequently long variable names are not allowed...
>
> Can anyone tell me how to get SAS data (ver 8) into R (easily)?
>
> Thanks in advance

Frank Harrell's Hmisc library has very nice tools for importing SAS v8 data
sets to S-Plus. Hence, that library might provide what you want when it is
ported to R. I, for one, am very much looking forward to using Hmisc under
R.

Meanwhile, you could use "proc export" in SAS to write out your data to a
text file, and then use "read.table" (or, equivalent) to read it into R. For
example, on a Windows you might write code similar to the following.

In SAS...

proc export data=iris
    outfile="c:\data\iris.csv"
    replace;
run;

In R...

iris.data <- read.csv("c:/data/iris.csv")
names(iris.data) <- tolower(names(iris.data))

-Bill

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list