On the face of it, Zurab has been bitten by an anomaly in -egen,
group()-.
Given no varlist, or not given any varlist, the function does not
complain. This is perhaps a small surprise, not least because this case
is not discussed in the documentation.
There is another quite different take.
What Zurab supplied was a varlist: it was just a limiting case, namely
an empty varlist (I prefer not to say "missing varlist", because that
conjures up all sorts of ideas about missing values, not the issue
here). If you
look at the code with
. viewsource _ggroup.ado
you'll see that the program works fine with an empty varlist. Apart from
any exclusions implied by -if- or -in-, if no varlist is supplied then
all
observations end up in the same group. That seems logical to me.
Whether it was intentional I can't say, but that's immaterial.
Unconscious
logic is just as valid as conscious logic.
It's StataCorp's call, but in cases like this I wouldn't disturb
longstanding code.
There is not much context here, but presumably this is happening
unlooked-for in a program or do-file of Zurab's. If so, the easiest
thing is trap the problem just upstream, say by
if trim("`varlist'") == "" {
* code handling this
}
else egen <newvar> = group(`varlist')
Alternatively, strip off the overhead of -egen- and program what
you want directly.
Note that there are plenty of precedents for empty varlists, just
a difference on whether the user really means nothing or really
means everything possible (e.g. -list-, -summarize-).
Nick
[email protected]
Zurab Sajaia
I just found out that -group- function of the -egen- family works with
missing varlist as well, i.e. egen newvar=group() doesn't issue an error
but
create newvar that equals to 1. I was using -capture- to catch the cases
with missing varlist but it never returned an error code ...
I guess I'll need to change my program but was wandering whether this is
a
bug or normal behavior (then it might need to be mentioned in the help).
btw, I'm (still) using Stata 9.2 ...
*
* 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/