Statalist


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

Re: st: Count observations per year


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Count observations per year
Date   Tue, 12 Feb 2008 09:24:29 -0500

Dascha Orlova <[email protected]>--
Try:

g n=1
collapse (count) n, by(firm year)
fillin firm year
replace n=0 if mi(n)


On Feb 12, 2008 9:04 AM, Dascha Orlova <[email protected]> wrote:
> Dear Statalisters,
>
> my question is fairy basic but I fail to find a solution myself. I have a sample of projects of N firms from 1990 till now. It looks this:
>
> year firm inventory
> 1990 X1    a
> 1990 x2    b
> 1990 x3    c
> 1990 x3    d
> 2000 x2    e
> 2000 x3    f
>
> The problem is: the only thing I am really interested in is the number on the projects per firm per year. So it should look like this:
>
> firm inv1990 inv2000
> x1   1       0
> x2   1       1
> x3   2       1
>
> Is there any count function which I can apply to modify my dataset like this given that the number of firms is quite large?
*
*   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