Statalist


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

Re: st: Count observations per year


From   "krishanu karmakar" <[email protected]>
To   [email protected]
Subject   Re: st: Count observations per year
Date   Tue, 12 Feb 2008 19:58:47 +0530

I take the liberty of assuming that a, b, c, d etc in the variable
"inventory" does not mean anything in particular (That is they are not
codes for number of inventories)

In that case I think the following set of commands will do

sort year firm
generate inv=1
egen inventory_count=total(inv), by( year firm)
duplicates drop firm year, force
drop  inventory
reshape wide inventory_count, i(firm)  j(year)

Krishanu


On Feb 12, 2008 7:34 PM, 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?
>
> Thanks for your help!
>
>
> --
> Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! Spa�garantie pur:
> http://games.entertainment.web.de/de/entertainment/games/free
> *
> *   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/
>



-- 
Read it: http://www.stata.com/support/faqs/res/statalist.html
Specially Question 3.

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