You have been on this list for some time and
asked many questions, but it doesn't seem
that you are making much use of the help
facilities, including -search- and the FAQs.
I am not clear what the precise underlying question is
here, but the answer is definitely Yes.
There are many alternatives.
Much depends on what you mean by identifier. I
take that to mean ideally that each observation
can be identified uniquely. If no such variable
exists, it can always be created with
. gen long id = _n
For much more discussion, see
FAQ . . . . . . . . . . . . . . . . . . . . . . Creating group identifiers
3/01 How do I create individual identifiers numbered
from 1 upwards?
http://www.stata.com/support/faqs/data/group.html
As far as -egen, group()- is concerned, -by:- indeed can't be
used with it. But that functionality is completely
unnecessary. If -by:- were allowed it would just
act if it were the first variable you specified. So
whatever variable you want as a -by:- argument
should be the first named. So instead of
. egen group = group(b a), by(c)
or
. by c: egen group = group(b a)
you just go
. egen group = group(c b a)
But -group()- generates grouping variables, which in
general are not identifiers.
Either way: -egen, group()- is just an application of -by:-
in any case. For more control in this and many other problems,
you need to master -by:- directly. There is a tutorial at
SJ-2-1 pr0004 . . . . . . . . . . Speaking Stata: How to move step by: step
Q1/02 SJ 2(1):86-102 (no commands)
explains the use of the by varlist : construct to tackle
a variety of problems with group structure, ranging from
simple calculations for each of several groups to more
advanced manipulations that use the built-in _n and _N
Nick
[email protected]
Terra Curtis
> Since the -egen- function -group- cannot be combined with
> "by", does anyone
> know if there is an alternative method (or Stata function)
> for creating an
> ID within a varlist?
>
> PS - I am using Stata 8.
*
* 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/