Hello R folk
I have an xpt file which I have been trying to open into R in R studio On the net I found guidance which says that I need packages Hmisc and SASxport which I have successfully loaded. I had also found some code which says that this would allow me to read the xpt file into R: library(SASxport) data(Alfalfa) lookup.xport("test.xpt") Alfalfa<-read.xport("test.xpt") I have set the directory correctly as far as I am aware, but when I tried to run this code I got the following error messages: > lookup.xport("test.xpt") Error in lookup.xport.inner(file) : file not in SAS transfer format > Alfalfa<-read.xport("test.xpt") Error in read.xport("test.xpt") : The specified file does not start with a SAS xport file header! I neither know what the file being not in SAS transfer format means, nor what not starting with an SAS xport file header means either... If anyone can explain how I can read this xpt file into R I'd be v grateful Thanks Nick Wray [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
> On Apr 13, 2018, at 10:01 AM, WRAY NICHOLAS via R-help <[hidden email]> wrote: > > Hello R folk > > I have an xpt file which I have been trying to open into R in R studio > > On the net I found guidance which says that I need packages Hmisc and SASxport which I have successfully loaded. > > I had also found some code which says that this would allow me to read the xpt file into R: > > library(SASxport) > data(Alfalfa) > lookup.xport("test.xpt") > Alfalfa<-read.xport("test.xpt") > > I have set the directory correctly as far as I am aware, but when I tried to run this code I got the following error messages: > >> lookup.xport("test.xpt") > Error in lookup.xport.inner(file) : file not in SAS transfer format >> Alfalfa<-read.xport("test.xpt") > Error in read.xport("test.xpt") : > The specified file does not start with a SAS xport file header! > > I neither know what the file being not in SAS transfer format means, nor what not starting with an SAS xport file header means either... The "export" or "transfer format from SA is supposed to make reading data less difficult and standardized. This is what a header from the version used by the NHANES releases (that's all one line): HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!000000000000000000000000000000 SAS SAS SASLIB 9.2 XP_PRO 16SEP09:09:39:2516SEP09:09:39:25 HEADER RECORD*******MEMBER HEADER RECORD!!!!!!!000000000000000001600000000140 HEADER RECORD*******DSCRPTR HEADER RECORD!!!!!!!000000000000000000000000000000 SAS DEMO SASDATA 9.2 XP_PRO 16SEP09:09:39:2516SEP09:09:39:25 HEADER RECORD*******NAMESTR HEADER RECORD!!!!!!!000000014400000000000000000000 |