Hi, SAS transport files created with the xport engine in SAS can be read using read.xport. However, the xport engine only works with SAS version 6, and consequently long variable names are not allowed... Can anyone tell me how to get SAS data (ver 8) into R (easily)? Thanks in advance S?ren H?jsgaard sorenh at agrsci.dk http://www.jbs.agrsci.dk/~sorenh ------------------------------------------------------------------------- Time flies like an arrow, fruit flies like a banana. ------------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
----- Original Message ----- From: "S?ren H?jsgaard" <sorenh at mail.dk>> Hi, > > SAS transport files created with the xport engine in SAS can be read usingread.xport. However, the xport engine only works with SAS version 6, and consequently long variable names are not allowed...> > Can anyone tell me how to get SAS data (ver 8) into R (easily)? > > Thanks in advanceFrank Harrell's Hmisc library has very nice tools for importing SAS v8 data sets to S-Plus. Hence, that library might provide what you want when it is ported to R. I, for one, am very much looking forward to using Hmisc under R. Meanwhile, you could use "proc export" in SAS to write out your data to a text file, and then use "read.table" (or, equivalent) to read it into R. For example, on a Windows you might write code similar to the following. In SAS... proc export data=iris outfile="c:\data\iris.csv" replace; run; In R... iris.data <- read.csv("c:/data/iris.csv") names(iris.data) <- tolower(names(iris.data)) -Bill -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Soren, The following code runs just fine from SAS V.8 and imports into R without a hitch: libname xxx sasv5xpt 'yourfilenamehere'; data xxx.dat; set perm.yoursasv8data; run; Hope this helps. Cheers, Patrick> Date: Thu, 23 Aug 2001 23:04:05 +0200 > From: =?iso-8859-1?Q?S=F8ren_H=F8jsgaard?= <sorenh at mail.dk> > Subject: [R] Reading SAS version 8 data into R> Hi,> SAS transport files created with the xport engine in SAS can be readusing read.xport. However, the xport engine only works with SAS version 6, and consequently long variable names are not allowed...> Can anyone tell me how to get SAS data (ver 8) into R (easily)?> Thanks in advance> S?ren H?jsgaard > sorenh at agrsci.dk http://www.jbs.agrsci.dk/~sorenh > -------------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> -----Original Message----- > From: Patrick McKnight [mailto:pem at theriver.com] > Sent: 24. august 2001 06:59 > To: r-help at lists.R-project.org > Subject: Re: [R] Reading SAS version 8 data into R > > > Soren, > > The following code runs just fine from SAS V.8 and imports > into R without > a hitch: > > libname xxx sasv5xpt 'yourfilenamehere'; > > data xxx.dat; > set perm.yoursasv8data; > run;No it does unfortunely not. Try the following in SAS v8, and you will see exactly that the long variable names causes problems. Apparently there is no way around shortening your variable names, except writing SAS-programs that punches data on to flat files. Data x8 ; input x y a_k verylongname ; cards; 1 2 3 4 2 . 4 6 5 6 7 . 4 5 8 8 ; Run ; * This is OK ; Libname zzz xport "dataset.xpt"; Data zzz.first3 ; Set x8 ( keep = x y a_k ) ; Run ; * This will fail ; Libname xxx xport "longdat.xpt"; Data xxx.all; Set x8 ; Run ; ---------------------- Bendix Carstensen Senior Statistician Steno Diabetes Centre Niels Steensens Vej 2 DK-2820 Gentofte Denmark tel: +45 44 43 87 38 mob: +45 28 25 87 38 fax: +45 44 43 73 13 bxc at novo.dk www.biostat.ku.dk/~bxc ----------------------> > > Hope this helps. > > Cheers, > > Patrick > > > > > Date: Thu, 23 Aug 2001 23:04:05 +0200 > > From: =?iso-8859-1?Q?S=F8ren_H=F8jsgaard?= <sorenh at mail.dk> > > Subject: [R] Reading SAS version 8 data into R > > > Hi, > > > SAS transport files created with the xport engine in SAS > can be read > using read.xport. However, the xport engine only works with > SAS version 6, > and consequently long variable names are not allowed... > > > Can anyone tell me how to get SAS data (ver 8) into R (easily)? > > > Thanks in advance > > > S?ren H?jsgaard > > sorenh at agrsci.dk http://www.jbs.agrsci.dk/~sorenh > > - > -------------------------------------------------------------- > ----------- > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.-.-.-.-.-.-.- > r-help mailing list -- Read > http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: > r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._