Statalist


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

st: Adding cumulatively


From   "Rijo John" <[email protected]>
To   stata <[email protected]>
Subject   st: Adding cumulatively
Date   Thu, 15 May 2008 11:24:22 -0500

Hi I have a data as follows.

Year  ID  var1 var2
1       1     4    6
2       1     5    8
3       1     2    2
4       1     3    7
1       2     5    1
2       2     7    5
3       2     6    4
4       2     4    9

I need cumulative sums of var1 and var2 by ID

so that it will become

Year  ID  var1 var2 cumvar1 cumvar2
1       1     4    6        4          6
2       1     5    8        9         14
3       1     2    2       11        16
4       1     3    7       14        23
1       2     5    1        5          1
2       2     7    5       12         6
3       2     6    4       18       10
4       2     4    9       22       14


I have more than two vars. Can some one please help.

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