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

Re: st: varlist


From   Babigumira Ronnie <rutaremwa_rb@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: varlist
Date   Thu, 11 Jul 2002 09:04:59 -0700 (PDT)

Hi  Ken Higbee    
Thanks for the help, I will try to explain my problem to you using your
example. 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?

Thanks

Roni

--- khigbee@stata.com wrote:
> Babigumira Ronnie <rutaremwa_rb@yahoo.com> asks:
> 
> > I have 3 variables percr100 percr200 percr300 (perennial crops grown),
> I
> > know the range of these crops so I list illegal entries for percr100
> using
> > 
> > egen perbc1 = eqany(percr100), v(-7 440/446 660/670 770/789)
> > list houscode percr100 if !perbc1
> > 
> > then I look at the manual and eqany can be followed by varlist so
> instead
> > of doing the above for all the three, I
> > 
> > egen perbc = eqany(percr100 percr200 percr300), v(-7 440/446 660/670
> > 770/789)
> > list houscode percr100 percr200 percr300 if !perbc
> > 
> > And the results are wrong, it appears that only the first variable was
> > inspected. Did I just misinterpret eqany. In the event that I did
> (very
> > likely) whats the way out
> 
> Can you show us an example of how the results were wrong?  Here
> is a simple example I ran that worked just fine.
> 
>     . set obs 10
>     obs was 0, now 10
> 
>     . gen a = _n
> 
>     . gen b = _n+2
> 
>     . gen c = _n+4
> 
>     . egen z = eqany(a b c) , values(1 4 9 12)
> 
>     . list
> 
>                  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
> 
> Ken Higbee    khigbee@stata.com
> StataCorp     1-800-STATAPC
> 
> *
> *   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/


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com
*
*   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