[R] Importing SAS datasets into R efficiently

Marc Schwartz m@rc_@chw@rtz @end|ng |rom me@com
Fri Oct 19 17:05:52 CEST 2018


Hi,

'foreign' will only read SAS XPT files, not the proprietary BDAT files, which I presume is the case here.

I don't use 'haven', but it looks like the key functions are written in C/C++, which should be relatively efficient.

If you are having specific issues with particular files,  because they are rather large, and/or have some kind of complex structure, you might want to communicate directly with the haven maintainers to see if there are some performance bottlenecks that perhaps they can resolve.

The only other option, to my knowledge, to directly read BDAT files in R, is the sas7bdat package on CRAN:

  https://cran.r-project.org/web/packages/sas7bdat/ <https://cran.r-project.org/web/packages/sas7bdat/>

However, it looks like it has not been updated in several years, so not sure of status.

Another alternative, if you have access to SAS, is to export the BDAT datasets(s) to CSV files in SAS, and them import them into R, using read.csv().

Regards,

Marc Schwartz


> On Oct 19, 2018, at 10:41 AM, Bert Gunter <bgunter.4567 using gmail.com> wrote:
> 
> Have you looked at the "foreign" package?
> 
> -- Bert
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Fri, Oct 19, 2018 at 6:48 AM Jomy Jose <infojomy using gmail.com> wrote:
> 
>> Hi
>> 
>> Is there an efficient way to import SAS datasets into R,presently while
>> using haven package it takes long time...Is there a smart work around this
>> ?
>> 
>> Thanks in advance
>> Jose


	[[alternative HTML version deleted]]




More information about the R-help mailing list