Statalist The Stata Listserver


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

st:Creating aggregated new observations


From   [email protected]
To   [email protected]
Subject   st:Creating aggregated new observations
Date   Thu, 13 Jul 2006 23:10:05 -0600

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index