Re: [R] Can R replicate this data manipulation in SAS?

From: Ista Zahn <>
Date: Fri, 22 Apr 2011 10:34:52 -0400

Hi Paul,

On Fri, Apr 22, 2011 at 10:21 AM, Paul Miller <> wrote:
> Hello Everyone,
> It seems to me that Bertís assertion about my question is not entirely accurate.
> In my question, I wrote:
> I'm hearing in some places that R may not be able to accomplish all of the data manipulation tasks that SAS can. In others, I'm hearing that R can do pretty much any data manipulation that SAS can but the way in which it does so is likely to be quite different.
> It's not clear to me how this represents a "wrong question," in the sense that it implies that R should solve the problem in the same way that SAS does.
> I really liked Istaís solution, but now Iím wondering if itís an attempt to mimic SAS and not a solution thatís natural to R.
> Is there another solution that is more natural in R? And if so, what would it look like?

R is flexible, which is one of the things I like most about it. That flexibility means you can do almost any given task in more than one way. This can sometimes lead to the question "which is the best way", which may be interesting but in my experience is almost always a waste of time (this statement is ment to apply to data manipulation/analysis, not nesessarily to package development). Of course you don't want to make things more complicated than they have to be, and you of course want to get the right result in the end. But my view is that when manipulating/analyzing data one should strive for a "good enough" solution and not worry too much about finding the "best" one. So while I'm sure someone can improve on my solution, it works, is relatively easy to follow, and is not overly verbose. Good enough I say.

I should also note that I don't understand SAS speak at all. I did NOT translate your SAS code (except for the HARRT part, where a direct translation seemed like the easies thing to do) -- in fact the first thing I did was copy your email to a text editor and delete all the SAS stuff. The way I arrived at the solution was just by looking at the output you wanted and producing it in R in the way that seemed most natural to me. Would someone else do it differently? Yes. Could someone else do it better? Yes. But is it worth the time to try and find a better way? I doubt it.


> Thanks,
> Paul

Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 22 Apr 2011 - 14:53:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Apr 2011 - 15:00:32 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive