[R] How to this SAS transport file in R?

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Mon Dec 6 07:29:38 CET 2010

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of zhiji19
> Sent: Sunday, December 05, 2010 9:26 PM
> To: r-help at r-project.org
> Subject: [R] How to this SAS transport file in R?
> Dear All,
> I try to read the SAS transport file in R, but it shows error. Please
> help!
> I am using R 2.11.1
> library(foreign)
> download.file("http://isites.harvard.edu/fs/docs/icb.topic35387.files/d
> emo_c.xpt","C:/Desktop/demo_c.xpt")
> sasxport <- read.xport("C:/Desktop/demo_c.xpt")
> Error in lookup.xport(file) : file not in SAS transfer format

I think You need to use mode='wb' in your download statement

              "C:/Desktop/demo_c.xpt", mode='wb')

Hope this is helpful,


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