[R] suggestions about import SAS Transport files to R.
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Tue Mar 26 20:01:28 CET 2013
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Duncan Murdoch
> Sent: Tuesday, March 26, 2013 11:32 AM
> To: Santosh
> Cc: r-help at r-project.org
> Subject: Re: [R] suggestions about import SAS Transport files to R.
>
> On 26/03/2013 1:57 PM, Santosh wrote:
> > Dear Rxperts!
> >
> > My colleagues used SAS PROC COPY to generate the xpt files that could
> be
> > read by the available "xpt" file reading packages in R. However, I am
> > unable to use the R packages for reading SAS transport files
> generated
> > through SAS PROC CPORT. I have tried SASxport, Hmisc, and foreign.
>
> I thought I had heard that SAS was now distributing some way to connect
> to R. So shouldn't you be asking them this question?
>
> Duncan Murdoch
>
> >
> > Any ideas/suggestions are more than welcome!
> >
> > Thanks so much!
> > Santosh
> >
> > [[alternative HTML version deleted]]
> >
I may end up saying more than I know, and one of these days I may have the time to dig into the SAS to R pathway using SAS (but not yet). And as of now, SAS still does not make it easy to transfer data to R for use outside of the SAS environment. That said, SAS Proc Copy and Proc Cport create different portable file structures. I don't think the functions in the foreign package read Proc Copy transport files.
My preferred way of transferring SAS data sets to R is to use Proc Export to convert the files to Stata format. The foreign package reads these just fine, and you don't have to worry about truncating variable names as can happen with Proc Cport. The drawback is that "SAS Access for PC Files Formats" needs to be licensed on the SAS side.
Your colleagues can always use Proc Cport or use Proc Export and convert the files to CSV. Anyway you look at it, they need to recreate the files in a format that you can read.
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