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
[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/