Dear Kit,
Your code is great! Thank you very much. After some small modifications I can get what I want. Thank you!
Best Regards
Hua
-------- Original-Nachricht --------
> Datum: Sat, 21 Mar 2009 15:55:12 -0400
> Von: Kit Baum <[email protected]>
> An: [email protected]
> Betreff: st: re: Group building according to given report dates and company
> <>
> This should be much easier to handle in long format, which gets away
> from all the issues about how many reports there are per company.
>
> ------------
> clear
> input company year
> 1 1939
> 1 1945
> 1 1952
> 2 1938
> 2 1941
> 2 1946
> 2 1953
> 3 1937
> 3 1940
> 3 1948
> 3 1954
> end
> sort company year
> save reptdates, replace
> webuse grunfeld, clear
> drop if company > 3
> keep company year invest
> merge company year using reptdates, uniqusing
> g reptyear = (_merge == 3)
> drop _merge
> // transform reptyear to indicate the report period for each company
> bys company: replace reptyear = sum(reptyear)
> // calculate the sum of a firm-level variable over each report period
> bys company reptyear: g cuminv = sum(invest)
> bys company reptyear: g lastyear = _n == _N
> l company year reptyear cuminv if lastyear, sepby(company)
> --------------------
>
>
> Kit Baum | Boston College Economics and DIW Berlin |
> http://ideas.repec.org/e/pba1.html
> An Introduction to Stata Programming |
> http://www.stata-press.com/books/isp.html
> An Introduction to Modern Econometrics Using Stata |
> http://www.stata-press.com/books/imeus.html
>
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/