[R] Read SAS data into R

Marc Schwartz marc_schwartz at comcast.net
Fri May 11 21:40:42 CEST 2007

On Fri, 2007-05-11 at 13:43 -0500, Frank E Harrell Jr wrote:
> kseefeld wrote:
> > Kim’s EZ Recipe for….
> > 
> > SAS TO R, perfectly formatted table with no loss of data
> > 
> > •	In SAS: Export SAS DB as access db
> > •	In R go to directory where access db is stored
> > •	Use package RODBC
> > 
> > #R code
> > #Create connection object (Can set up DSN but I’m too lazy to)
> > c<-odbcConnectAccess("x.mdb")
> > #Create table object, store db in object
> > x<-sqlFetch(c, "test")
> > #Close connection object
> > odbcClose(c)
> > 
> > 
> That doesn't help people who don't have SAS.
> Note that an upcoming release of the Hmisc package has a new Access 
> import function for users who have access to the mdbtools package on 
> their operating system (e.g., linux).

mdbtools is also being used by the OO.org folks:


Just to follow up on Frank's prior post regarding the SAS System Viewer,
that does work well under Wine on Linux, with the caveat that Frank

I also use DBMS/Copy under Wine and that works quite well.

One of the advantages of DBMS/Copy versus the System Viewer is wider
support for the proprietary SAS formats from various OSs. We recently
were in receipt of SAS datasets that were generated on a 64 bit Unix
platform. The SAS System Viewer choked on them, but DBMS/Copy had no

The SAS System Viewer is a free download, whereas DBMS/Copy is not, so
it places an emphasis on either getting SAS datasets from Windows based
installations or ensuring that the entity generating the datasets
outputs SAS Transport format files instead.


Marc Schwartz

More information about the R-help mailing list