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

RE: st: STATA Vs. SAS


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: STATA Vs. SAS
Date   Wed, 27 Nov 2002 20:28:55 -0000

Richard Herrell
> 
> On Wed, 27 Nov 2002, Nick Winter wrote:
> 
> > > -----Original Message-----
> > > > 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.
> 
> 
> Yes, that's what I meant.  In my simple example, using the Stata
> alternative isn't such a problem, but often I want to apply 
> a subcondition
> to only some values.  So, e.g.,
> 
> if x=0 then y=1;
> else if 1 < x < 10 then do;
>   <other sas commands>;
> end;
> else if 11 < x < 20 then do;
>   <other sas commands>;
> end;
> 
> 
> It's difficult and tedious to have to write the multiple levels of
> conditions if the program is going to evaluate every if statement.

I am still not clear whether -x- and -y- are variables, 
and whether this all -- in Some Alternative
Software -- is tacitly looping over 
observations. (In my case, please assume 
complete ignorance of SAS.) 

I will also add that I don't find often myself 
wanting to use completely different 
commands for different subsets of a variable. 
Alternatives could depend on what those 
commands are. 

Nick 
[email protected] 
*
*   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