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/demo_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 -- View this message in context: http://r.789695.n4.nabble.com/How-to-this-SAS-transport-file-in-R-tp3073969p3073969.html Sent from the R help mailing list archive at Nabble.com.
You didn't tell us your OS. That is a binary file, and from ?download.file: mode: character. The mode with which to write the file. Useful values are ?"w"?, ?"wb"? (binary), ?"a"? (append) and ?"ab"?. Only used for the ?"internal"? method. Only on Windows are the binary modes different, so it looks like you forgot mode="wb". On Sun, 5 Dec 2010, someone ashamed of her real name wrote:> 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/demo_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[...]> PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlYes, that does mean you. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
I've had good success with the read.xport function in the SASxport (not foreign) package. But couldn't you just use something like mydata<-read.xport('http..../demo_c.xpt') The transport file looks like it's one of the NHANES demographic files. -- View this message in context: http://r.789695.n4.nabble.com/How-to-this-SAS-transport-file-in-R-tp3073969p3074009.html Sent from the R help mailing list archive at Nabble.com.
> -----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 download.file("http://isites.harvard.edu/fs/docs/icb.topic35387.files/demo_c.xpt", "C:/Desktop/demo_c.xpt", mode='wb') 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