bysort id (year) : gen cumvar1 = sum(var1)
Skim through the help on functions for problems like these.
Nick
[email protected]
Rijo John
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.
*
* 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/
_____________________________________________________________________
Mensaje analizado y protegido por Telefonica Empresas
*
* 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/
Privileged, confidential or patient identifiable information may be contained in this message. This information is meant only for the use of the intended recipients. If you are not the intended recipient, or if the message has been addressed to you in error, do not read, disclose, reproduce, distribute, disseminate or otherwise use this transmission. Instead, please notify the sender by reply e-mail, and then destroy all copies of the message and any attachments.
*
* 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/