|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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/