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   [email protected]
To   [email protected]
Subject   RE: st: Create the count of occurances in a panel
Date   Fri, 22 Apr 2005 12:16:23 -0400 (EDT)

That's right.  Sorry for ignoring the second line of Svend's code...
Interesting to see different programs to generate the same outcome..

Thanks again..


> Thanks for summarising the thread. Note,
> however, that Svend's solution also
> included exactly what you asked for
> (see bottom line of his message).
>
> Nick
> [email protected]
>
> [email protected]
>
>> Thanks all for answering me this.  All provide me with very useful
>> information.  For future reference,  I summarize each method.  Matt's
>> method generates the total count of occurances for each ID,
>> but collapses
>> the data.  Svend sets a record number for each ID.  Nick's method is a
>> shortcut to what I am looking for.  Thanks again.
>
>> > 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/
>


Ying Wang
Ph.D. Candidate
Department of Public Policy
University of Maryland, Baltimore County
1000 Hilltop Circle,
Baltimore, MD 21228
Tel(O): 410-455-6531
Tel(H): 410-747-6980
Fax: 410-455-1172
Email: [email protected]


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