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

RE: st: STATA Vs. SAS


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: STATA Vs. SAS
Date   Wed, 27 Nov 2002 19:54:30 -0000

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_. 

If this is a problem in producing a single 
value -- held in Stata as a macro or 
a scalar -- given another macro or 
scalar, then the code should be 
of this form  

if `x' == 0 { 
	local y = 1 
} 
else if `x' > 1 & `x' < 10 { 
	local y = 2 
} 
else if `x' > 11 & `x' < 20 { 
	local y = 3 
} 
else local y = . 

Nick 
n.j.cox@durham.ac.uk 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index