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

st: -egen, eqany()-

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: -egen, eqany()-
Date   Tue, 9 Jul 2002 15:49:33 +0100

On 27 June Daniel Caro posted a question 
about -egen, eqany()-, to which I replied. 

On 8 July Ronnie Babigumira posted a question
about the same function, to which Thomas Steichen
and I replied. 

Both Daniel and Ronnie have the same underlying 
problem: selecting a subset of observations when 
the selection is specified by a very complicated 
-if- condition. -egen, eqany()- in essence offers 
a short-cut way of doing that which imposes less 
typing than the brute force but tedious method 
of typing out a compound -if- condition, so long 
as the -if- condition is equality with any of 
a set of integer values. 

The little history of this little function is 
like a fair fraction of Stata: originally, if I recall 
correctly, it was written in response to a 
question on Statalist; thereafter it was 
published and then revised in STB-50 and STB-57; 
currently, it has been adopted as part of official
Stata. I was the original author and retain some 
kind of parental feeling. After discussions
with Stata Technical Support, I now attempt to 
close this thread. 

To cut a long and not especially interesting story 
short, and omitting red herrings, false alarms 
and unjustified aspersions: 

1. -egen, eqany()- was crashing when presented 
with a very long argument for -values()-. There 
will be a limit to what Stata can cope with here, 
but the limit imposed by -eqany()- is lower than 
necessary because of redundant code which had an 
unwanted side-effect. Rewritten code removes the 
redundancy and the performance of -eqany()- improves. 
I have drafted a fixed version which Stata Corp 
will test and hope to include in the next ado 

2. The same problem would arise, and the same 
kind of fix will apply, to the perhaps less often
used -egen, neqany()-. 

In both cases, there are no backward implications
for applications which worked without crashing. 

3. More positively, the thread highlighted 
a method of selecting observations using -merge- 
which for very complicated selection conditions 
is both simple and attractive. Sooner or later
I will try to write this up, either as an FAQ submitted
to the Stata website, or in some other form. 
The idea of using -merge- here is one I owe to 
Kit Baum. 

[email protected] 

*   For searches and help try:

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