Statalist


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

RE: st: Count observations per year


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Count observations per year
Date   Tue, 12 Feb 2008 17:22:16 -0000

contract firm year, zero 

is equivalent to these four lines of code. To get Dascha's desired
result, you would follow by a -reshape-. 

Nick 
[email protected] 

Austin Nichols

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

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

Dascha Orlova

> 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