Richard Williams
> >Let's not lose sight of where we started.
> >Stata has standard constructs
> >
> >if ... {
> >
> >}
> >else {
> >
> >}
> >
> >too; the point is that the conditional
> >testing cannot be vectorised.
>
> Just so I'm clear as to what you mean: If I understand
> this correctly, if
> the statement is something like
>
> if x1==1 {
>
> and x1 = 1 for the FIRST case, then the statement is true,
> otherwise false;
> it won't matter what x1 = for the 2nd case. So, this kind
> of structure is
> not useful for case by case changes. It is useful for
> things like your earlier
>
> if r(N) == 0 su mpg
>
> where the value of r(N) (or whatever) is not going to
> change case by case. Sound right?
That is correct. Some examples of this -if- in programs
are
1. testing a string
if "`option'" != "" {
// some option was specified, so
...
}
else {
...
}
2. testing a result
qui count if `touse'
if r(N) == 0 error 2000
3. testing an observation value
if x[1] < 0 {
...
}
This last kind of thing might
make sense, especially after
a -sort-. It's perhaps more
common to do something more
like
su x, meanonly
if r(min) < 0 {
...
}
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/