Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: STATA Vs. SAS


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   RE: st: STATA Vs. SAS
Date   Wed, 27 Nov 2002 15:01:18 -0500

> -----Original Message-----
> From: Nick Cox [mailto:[email protected]] 
> Sent: Wednesday, November 27, 2002 2:55 PM
> To: [email protected]
> Subject: RE: st: STATA Vs. SAS
> 
> 
> Richard Herrell
> 
> > On Wed, 27 Nov 2002, Nick Cox wrote:
> > 
> > > Richard Herrell
> > > >
> > > > if x=0 then y=1;
> > > > else if 1 < x < 10 then y=2;
> > > > else if 11 < x < 20 then y=3;
> > > > else y=.
> > 
> > In SAS, the code exits the structure when a true condition 
> > is met.  In
> > Stata, every if condition is evaluated even after the true 
> > condition is
> > met.
> 
> Perhaps we are not talking about 
> the same thing here. I was assuming 
> that -x- and -y- are _variables_. 
> 

I took Richard's point to be that, *for each observation*, the
evaluation of conditions only need take place until a true condition is
found for *that observation*.  So, in the Stata code, Stata will
evaluate three conditions per observation; SAS will evaluate fewer than
that, depending on which conditions apply to which cases.

I'd be curious to hear someone from StataCorp's thoughts on this -
comparing efficiency of different conditional structures, across
programs, seems difficult at best.  Stata seems to have put a lot of
work into making internal replacements over observations extremely fast
and efficient.  If that process is much more efficient than SAS's
movement through conditions within observations, then the efficiency
advantage could well go to Stata.

--Nick WInter
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index