[R] Read SAS data

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Thu Mar 25 19:32:26 CET 2010


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Nicola Sturaro Sommacal
> Sent: Thursday, March 25, 2010 9:16 AM
> To: r-help at r-project.org
> Subject: [R] Read SAS data
> 
> Hi!
> 
> I need to import in R some SAS dataset (sas7bdat). I found two functions to
> do it:
> "read.ssd" from the package "foreign" and "sas.get" from "Hmisc".
> 
> df = read.ssd(libname = path2data, sectionnames = "sasSmallDataset",
> tmpXport = path2data, tmpProgLoc = path2data, sascmd = path2sas)
> sas.get(libraryName = path2data, member = "sasSmallDataset", formats =
> FALSE, sasprog = path2sas, keep.log = TRUE)
> 
> where path2data is the directory on which is contained the file sas,
> sasSmallDataset.sas7bdat are the data and path2sas is the path to SAS
> (C:/Programmi/SAS/SAS System/9.0/sas.exe).
> 
> I obtain the following messages:
> 
> from read.ssd:
> SAS failed.  SAS program at Z:/projects/QUANTIDE/import2R/.sas
> The log file will be import2R.log in the current directory
> Warning messages:
> 1: In file.symlink(oldPath, linkPath) :
>   symlinks are not supported on this platform
> 2: In read.ssd(libname = path2data, sectionnames = "sasSmallDataset",  :
>   SAS return code was 2
> 
> from sas.get:
> Error in if (status != 0) { : argument is of length zero
> 
> I have SAS 9.0 and R 2.10.1 running on Windows XP Pro.
> 
> Can you help me to found a solution or can you provide an alternative way to
> import SAS data directly from R?
> 
> Thank you very much.
> 
> --
>  Nicola Sturaro Sommacal
> Quantide srl
> 
> http://www.quantide.com

Here is one work-around for sas.get on MS Windows platforms.

http://finzi.psych.upenn.edu/Rhelp10/2008-December/182573.html

Here is another thread that you might find useful.

http://tolstoy.newcastle.edu.au/R/e9/help/10/02/6248.html

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204



More information about the R-help mailing list