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

st: Re: eqany

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: Re: eqany
Date   Mon, 8 Jul 2002 16:07:12 +0100

Ronnie Babigumira wrote 

I am cleaning data (that's all I seem to be doing) and I am a little
puzzled here. A while ago, I asked on how to identify illegal entries when
a variable takes on values in batches (e.g. 11 to 19 21 to 25 etc). Nick
Cox pointed me to 

. egen OK = eqany(cropcod2), values(110/120 220/227 330/334 440/446)
. list houscode cropcod2 if !OK

This has very well for, however, today I tried  

. egen OK = eqany(inpcode), values(500/505 599 601 1100/1111 /*
. */ 1200/1201 2100/2160/ 2200/2220 2299 2300/2302)
. list houscode inpcode if !OK 

I get an error message;

. egen OK = eqany(inpcode), values(500/505 599 601 1100/1111 /*
> */ 1200/1201 2100/2160 2200/2220 2299 2300/2302)
varlist not allowed

Any one familiar with this and a way around it?

>>> Tom Steichen identified a typo in what is above. However, 
I suspect that this typo is just in what Ronnie sent to the list
and that there is something more fundamental here. 

My answer is just a variation on the answer to Daniel 
Caro on 28 June. 

You are, I believe, tripping some limitation to the built-in
command -numlist-, which is called by -egen, eqany()-. If 
I am right, this can be shown directly by pushing your numlist
at -numlist-. 

An alternative for this problem is the use of -merge- as a variation on a
trick documented by Kit Baum at

Put the values you want to select as a single variable in one
Stata .dta file and then -merge- it with your main data file. 
The observations you want are the intersection of the two, 
for which _merge == 3. You can choose either one-to-one or match merging.

[email protected]

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index