Stephen Arthur
2002-Dec-25 05:16 UTC
Part II Re: [R] read.ssd {foreign} (Reading a permanent SAS d ataset into an R data frame)
Scot, Thanks for the info. I will try your code out to verify the result, but before I do that, will your code (SAS and R) work with variable names that are longer than 8 characters long without truncating the variable name in R? Also, I wonder about using your method or the PROC EXPORT method with larger data sets. The data sets I will be working with for the most part will not be that large, but for larger data sets, I do not like to create the intermediate csv file that PROC EXPORT creates because I do not like having unused files stored on my computer. Thanks, Stephen --- Scot W McNary <smcnary at fellspt.charm.net> wrote:> > > Stephen, > > I use SAS a lot and have to admit I use the proc > export version to csv > format you posted on a regular basis, however, I was > able to get the > transport version to work by using the xport engine > in a libname statement > as follows (SAS 8.2 on Windows98SE, rw1061): > > > # using SAS > libname check xport 'e:\testing.xpt' ; > > data a; > > do i = 1 to 10 ; > x = 1 + i ; > y = 50/x ; > output; > end; > > run; > > data check.a ; > set a ; > > run; > > proc print data = check.a ; > run; > > The SAS System 15:31 Tuesday, December 24, > 2002 1 > > Obs I X Y > > 1 1 2 25.0000 > 2 2 3 16.6667 > 3 3 4 12.5000 > 4 4 5 10.0000 > 5 5 6 8.3333 > 6 6 7 7.1429 > 7 7 8 6.2500 > 8 8 9 5.5556 > 9 9 10 5.0000 > 10 10 11 4.5455 > > # now reading into R > > > library(foreign) > > test<-read.xport("e:/testing.xpt") > > test > I X Y > 1 1 2 25.000000 > 2 2 3 16.666667 > 3 3 4 12.500000 > 4 4 5 10.000000 > 5 5 6 8.333333 > 6 6 7 7.142857 > 7 7 8 6.250000 > 8 8 9 5.555556 > 9 9 10 5.000000 > 10 10 11 4.545455 > > The tricky part for me is having to suspend the > metaphor of a "libname as > folder" and think of the libname check as pointing > to a file: > "testing.xpt". It works that way in trying to read > spss files with the > spss engine too. I would assume it's also true for > using bmdp and osiris > engines, but I haven't had occasion to use them. > > > Hope this helps, > > Scot > > > > -- > Scot W. McNary email:smcnary at charm.net > >
Apparently Analagous Threads
- Part II Re: read.ssd {foreign} (Reading a permanent SAS d ataset into an R data frame)
- the "union" of several data frame rows
- Part II Re: read.ssd {foreign} (Reading a permanent SAS d ataset into an R data frame)
- Part II Re: read.ssd {foreign} (Reading a permanent SAS d ataset into an R data frame)
- graphics backgrounds from gray to white in png()