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

Re: st: a question about panel data


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: a question about panel data
Date   Thu, 28 Jul 2005 16:00:13 -0400

Here's somebody suggesting a shorter way: you can replace the first 6 lines in the code below with 1 line (that will execute much faster):

bysort id: gen count=_N

Michael Blasnik
[email protected]

----- Original Message ----- From: "Dev Vencappa" <[email protected]>
To: <[email protected]>
Sent: Thursday, July 28, 2005 2:57 PM
Subject: Re: st: a question about panel data



>
Until somebody else suggests a shorter way, one way to do it is the following:

gen count=.
levels id, local (levels)
foreach l of local levels{
count if id==`l'
replace count=r(N) if id==`l'
}
duplicates drop id count, force
tab count

I think that should work

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