[R] Reading large SAS dataset in R

Abhijit Dasgupta adasgupta at araastat.com
Thu Jan 6 18:15:24 CET 2011


Santanu, 

I second Phil's suggestion. sas.get is actually quite nice. 

Another current option is using a command-line utility called dsread (http://www.oview.co.uk/dsread/) to convert the sas7bdat file to a csv or tsv format, which can then easily be read into R using read.table and its derivatives. Frank Harrell (author of the Hmisc package) commented positively on this approach on the list a couple of months back. 

Abhijit

On Jan 5, 2011, at 5:51 PM, Phil Spector wrote:

> Santanu -
>   If you have sas installed on your computer, you may find using
> the sas.get function of the Hmisc package useful.
>   If the only message that read.ssd produced was "Sas failed", it
> would be difficult to figure out what went wrong.   Usually the location of the log file, which would explain the error more thoroughly, is included in the error message.
> 
> 					- Phil Spector
> 					 Statistical Computing Facility
> 					 Department of Statistics
> 					 UC Berkeley
> 					 spector at stat.berkeley.edu
> 
> 
> On Wed, 5 Jan 2011, Santanu Pramanik wrote:
> 
>> Hi all,
>> 
>> I have a large (approx. 1 GB) SAS dataset (test.sas7bdat) located in the
>> server (?R:/? directory). I have SAS 9.1 installed in my PC and I can read
>> the SAS dataset in SAS, under a windows environment, after assigning libname
>> in "R:\" directory.
>> 
>> 
>> 
>> Now I am trying to read the SAS dataset in R (R 2.12.0) using the read.ssd
>> function of the ?foreign? package, but I get an error message ?SAS failed?.
>> I believe I have specified the paths correctly (after reading some previous
>> posts I made sure that I do it right). Below is the small code:
>> 
>> 
>> 
>> sashome<- "C:/Program Files/SAS/SAS 9.1"
>> 
>> read.ssd(libname="R:/", sectionnames="test", sascmd=file.path(sashome,
>> "sas.exe"))
>> 
>> 
>> 
>> Please let me know where I am making the mistake. Is it because of the size
>> of the file or the location of the file (in server instead of local hard
>> drive)?
>> 
>> 
>> 
>> Thanks in advance,
>> 
>> Santanu
>> 
>> 
>> -- 
>> --------------------------------------------------------------------
>> Santanu Pramanik
>> Survey Statistician
>> NORC at the University of Chicago
>> Bethesda, MD
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list