Date: Thu, 30 Dec 1999 18:06:16 -0000
Reply-To: "Vyverman, Koen" <koen.vyverman@FID-INTL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Vyverman, Koen" <koen.vyverman@FID-INTL.COM>
Subject: Re: Export SAS data to R (was RE: Creating Scatterplot Matrices i
n SA S)
Content-Type: text/plain; charset="iso-8859-1"
Rounding up a few things before the fateful year zero rollover,
I thought I'd provide an answer to my own question of about a
month ago. (since it's been a while, I take the liberty of
including the entire thread below the .sig)
The point was to enable myself to produce a summarized SAS data
set, export it somehow in a format that the freeware package R
can understand, and produce high-quality analysis graphs in R.
As Donald Cram pointed out, R's commercial cousin (or whatever
family member) Splus once had the ability to read SAS data sets
directly. Not so in R however. I found some traces on R-specific
mailing lists that some people are working on a SAS access module
for R, but nothing tangible exists as yet.
After some experimenting, the easiest way to accomplish what I
was after consisted in exporting the SAS data to a CSV file, and
using some basic R code to read this file and build an R data
sasdata <- read.table("Stuff from SAS.csv",header=TRUE,sep=",")
Where "Stuff from SAS.csv" is the CSV file written to the R-
session's current working directory. Header=true means that the
first line contains my comma-separated variable names.
The tricky bit was that the SAS 6.12 export-to-CSV functionality
did not work satisfactorily as it inserts blanks before the commas
after numerical variables. The read.table function in R does
not like this. So I wrote my own parametrized SASTOCSV macro
in order to have full control over the CSV output. Anyone
interested in a copy please feel free to contact me off-list.
I can now use the full graphical output toolbox of R to create
all sorts of enhanced metafile graphics that can be seamlessly
imported in e.g. M$ Powerpoint presentations, edited and rescaled
there if necessary, and look perfect when printed.
All this for the record. Perhaps it will be useful to someone,
Marketing Database Manager
Fidelity Investments - Luxembourg
Phone : (++352) 250 404 22 63
Fax : (++352) 250 404 22 08
> -----Original Message-----
> From: Donald Peter Cram [mailto:doncram@leland.Stanford.EDU]
> Sent: Tuesday, November 30, 1999 10:38 PM
> To: Vyverman, Koen
> Subject: Re: Export SAS data to R (was RE: Creating
> Scatterplot Matrices
> in SA S)
> In the Splus language (the commercial software to which freeware R is
> similar), there was a Splus function named dataget which would read a
> SAS dataset into an Splus object, perhaps the dataframe object. This
> was available at the StatLib website library at Carnegie-Mellon, a few
> years ago. I used it with great satisfaction. I noticed later that
> it was replaced on StatLib, superseded by some other more general
> function that I could not get to work. Anyhow, try StatLib and the
> s-news email list, to see if an R function is available.
> I don't know about a SAS macro to write an R-readable ASCII file.
> Don Cram
> In article <F97B12D29E75D211B75700A0C9DD020A725C3A@LXKAN716NTS>,
> Vyverman, Koen <koen.vyverman@FID-INTL.COM> wrote:
> >Funny that you should mention this at the very moment when
> >I'm messing around with the R package, and being generally
> >impressed with e.g. the scatterplot functionality :-) Not to
> >mention all the other math/stat/analysis goodies that are
> >freely available!
> >The R language and philosophy seem to be somewhat similar
> >to e.g. Matlab, so I found it not too difficult to produce
> >something nice with the sample data that are being provided.
> >Can't help you on the file-size issue, but graphical output
> >in R can be very easily saved as .emf and .ps, and provides
> >excellent hardcopy quality when imported into M$ Powerpoint.
> >Can't always say the same about SAS... *grumble*
> >Now, I'd like to export some of my own SAS data sets to the
> >R data format. The flatfile version of an R data set is pretty
> >clear, and it should be a rather straightforward exercise in
> >macro language in order to come up with a SAS macro that
> >writes a SAS data set in R/ASCII format.
> >Not wanting to reinvent any wheels, does anyone know whether
> >such an effort has already been undertaken? I tried to search
> >the list archives via dejanews.com, but searching for stuff
> >involving 'R' is pretty tedious...
> >Koen Vyverman
> >Marketing Database Manager
> >Fidelity Investments - Luxembourg
> >Phone : (++352) 250 404 22 63
> >Fax : (++352) 250 404 22 08
> >> -----Original Message-----
> >> From: brandon.paris@KODAK.COM [mailto:brandon.paris@KODAK.COM]
> >> Sent: Wednesday, November 10, 1999 11:31 PM
> >> To: SAS-L@LISTSERV.UGA.EDU
> >> Subject: Creating Scatterplot Matrices in SAS
> >> From: Brandon L. Paris
> >> Hello List --
> >> I'm trying to create several (about 50) scatterplot matrices
> >> of 6 variables
> >> each using SAS. To achieve this, I've managed to create a
> >> macro "wrapper"
> >> to call another macro written by Michael Friendly at York
> >> (speciffically, the scatmat.sas macro he has written).
> >> Unfortunately, this
> >> method produces nice scatterplots that are too large in
> >> filesize to print
> >> in a reasonable amount of time (the plots are between 3
> and 6 MB per
> >> matrix, depending on the number of observations). Is there
> >> another way to
> >> create scatterplot matrices in SAS that are not quite as
> >> large so I can
> >> print them? I can create similar (and smaller in file size)
> >> plots using
> >> other software packages, but I'd like to avoid moving data
> to another
> >> software package for only this issue. Does anybody have any
> >> suggestions?
> >> Any help would be greatly appreciated.
> >> Brandon L. Paris
> >> Statistician
> >> Eastman Kodak Company
> >> email@example.com