aggregate new observations.
Suppose I have a set of observations as follows
code year output
2011 1981 2
2013 1981 3
2021 1981 4
2022 1981 2
2023 1981 3
.
.
2011 1982 1
2013 1982 2
2021 1982 3
2022 1982 4
What I like to do is create aggregated new observations like this :
code year output
2000 1981 15 - new added obs (2+3+4+2+3)
2011 1981 2
2013 1981 3
2020 1981 9 -new added obs (4+2+3)
2021 1981 4
2022 1981 2
2023 1981 3
..
..
2000 1982 10 -new added obs(1+2+3+4)
2011 1982 1
2013 1982 2
2020 1982 7 -new added obs (3+4)
2021 1982 3
2022 1982 4
How do I add these outputs of both code 2000 (sum of all 5 observations) and
code 2020 ( sum of 2021 ,2022), respectively.
thanks so much.
WT
*
* 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/