Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: programming assist, too many unique values for levels


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: programming assist, too many unique values for levels
Date   Wed, 02 May 2007 13:29:30 -0400

Nick Cox wrote:
<snip>
4. In fact, you can do it directly without loops.
Michael might do it something like this.
(Note that Andrew already sorted by -pt-.

------------------------------------- #4
by pt : egen time = total(obstime)
--------------------------------------

5. However, this is more efficient, as
it avoids the interpretive overhead of -egen-
(-viewsource egen.ado- and -viewsource _gtotal.ado-
to see what I mean).

------------------------------------ #5
by pt : gen time = sum(obstime)
by pt : replace time = time[_N]
------------------------------------

Actually, I would use option 5 in my own do file, but I would recommend option 4 to anyone else unless I knew they were working on a large dataset where speed may be an issue.

Michael Blasnik
*
* 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/




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