Babigumira Ronnie replied to Ken Higbee:
Thanks for the help, I will try to explain my problem to you using your
example.
[Here's Ken's example -- NJC ]
>
> a b c z
> 1. 1 3 5 1
> 2. 2 4 6 1
> 3. 3 5 7 0
> 4. 4 6 8 1
> 5. 5 7 9 1
> 6. 6 8 10 0
> 7. 7 9 11 1
> 8. 8 10 12 1
> 9. 9 11 13 1
> 10. 10 12 14 1
Lets assume that a b and c are crops and we also know that they
can take on a given set of values 1 2 3 4 5 8 9 10 (as such 6 7 and
anything greater than 10 should be a problem and that's what I want to
flash out)
If we deal with them one by one
Starting with a and going thru
. egen ain = eqany(a), v(1/5 8/10) /*ain means a is in range*/
. list a if !ain /*all observations out of range*/
a
6. 6
7. 7
.
. egen bin = eqany(b), v(1/5 8/10)
. list b if !bin
b
4. 6
5. 7
9. 11
10. 12
.
. egen cin = eqany(c), v(1/5 8/10)
. list c if !cin
c
2. 6
3. 7
7. 11
8. 12
9. 13
10. 14
Now, here is my thinking, since a b and c take on the same range of
values, instead of going thru the above, I thought that (as you suggested)
. egen z = eqany(a b c) , v(1/5 8/10)
should list all the a's b's and c's out of the range, however, this is
what I get
. egen z = eqany(a b c) , v(1/5 8/10)
. list if !z
a b c z
Nothing is listed. So my question is that am I misusing the command?
>>> No misuse, but perhaps misunderstanding. -eqany()- answers
a question: is _any_ of the variables equal to _any_ of the values?
That is an inclusive question. Just one of the variables being
equal to one of the values is enough to qualify.
If you go through the observations one by one, you
will see that they all qualify; hence the complement is empty.
For your problems, you may find -assert- to be useful.
assert crop != 6 & crop != 7
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/