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

Re: st: counting unique ids


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: counting unique ids
Date   Tue, 07 Sep 2004 21:30:49 -0500

At 08:47 PM 9/7/2004 -0500, Kang, Eugene wrote:
Hi,

I have a cross-section panel data that is unbalanced. For instance:
id      year            x1
111     1999            3
111     2000            5
111     2001            6
123     2000            4
123     2001            2

For the above example, there are 2 unique ids (111 and 123). Since my
dataset has over 6000 observations, what commands should I use to generate a
count of unique ids?
One of many possible approaches:

. egen x = group(id)

. sum x

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
           x |         5         1.4    .5477226          1          2

The value for Max is the # of unique ids.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX:    (574)288-4373
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW (personal):    http://www.nd.edu/~rwilliam
WWW (department):    http://www.nd.edu/~soc

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