Skip to content

Importing Sas files to R

3 messages · Rekha, Daniel Nordlund, jthetzel

#
I presume you have SAS installed on your system and the path to the SAS.exe executable is in your Windows path environment variable, and the file, ex.sas7bdat, is in the root directory of your C: dive.  You might try something like 

try<-sas.get("C:/", "ex")

If SAS is not in your path then you will need to specify where to find it.  This would work on my system, your SAS location might be different.  The first parameter is libraryName and should contain the Windows directory where your dataset is located.  The second parameter is member and should contain the dataset name (without the sas7bdat extension)

try<-sas.get("C:/", "ex", sasprog= "C:/Program Files/SAS/SASFoundation/9.2/sas.exe")

If you don't have access to SAS on your system, this will not work.


Hope this is helpful,

Dan  

Daniel Nordlund
Bothell, WA USA
2 days later
#
Reka,

If you do not have SAS available, there is also a free program provided by
SAS called the SAS System Viewer, which will export sas7bdata files to csv. 
N.b. that I've heard it can be buggy if any character variables contain
unmatched quotes.  I've also read in a previous post
(http://r.789695.n4.nabble.com/Reading-sas7bdat-files-directly-td1469515.html)
of a program written by Chris Long called dsread
(http://www.oview.co.uk/dsread), which will do the trick.  I haven't used it
yet, but it sounds a lot better than fumbling through the SAS System Viewer.

Jeremy

Jeremy T. Hetzel
Boston University