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

RE: st: Create the count of occurances in a panel


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Create the count of occurances in a panel
Date   Fri, 22 Apr 2005 13:02:32 +0100

Yet another way is 

egen totobs = sum(1), by(id) 

(what is the observation number? 1 + 1 + 1 + ...)

or -- for slightly more subtle reasons -- 

egen totobs = count(1), by(id) 

Nick 
[email protected] 

Svend Juul
  
> bysort id: generate nobs=_n
> bysort id: generate totobs=_N

*
*   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