Buechte, Sebastian (Institut f�r Arbeitswissenschaften) wrote:
> David,
>
> honestly, nothing. Maybe its just too easy...
>
> But how would you influence how the values will be ordered for the
> numbering process? When using the bysort-thing, you can decide how the
> values will be ordered before the id is attached to them. When using
> egen's group function, do you have to sort the data before?
>
> Regards,
> sebastian
>
> > While both of the suggestions so far work fine, what is wrong
> > with just:
> >
> > egen id=group(firstname lastname dob)
Looking at the code of -_ggroup.ado-, which provides the functionality for
-egen-'s group function reveals that egen-group does nothing else than
. bysort firstname lastname dob: gen id = 1 if _n==1
. replace id =sum(id)
That said, there is nothing "bad" with -egen-.
One fine point, however is, that you should not use egen-group in an ado-file.
Egen is an ado-file, which calls an ado-file, which builds some more or less
complicated -generate- and -replace- sequences, which are than executed. An
ado-file will run faster if you program the -generate-/-replace- sequence
directly. This is easy to do, as you can get the lines from the respective
-egen- function. -egen- functions are always in ado-files starting with _g.
Look for _grsum.ado for the the -egen- function rsum(), etc.
uli
--
[email protected]
+49 (030) 25491-361
*
* 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/