Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Creating a variable


From   "Mike Kim" <[email protected]>
To   <[email protected]>
Subject   st: Creating a variable
Date   Sun, 27 Dec 2009 22:11:06 -0600

Dear all,

I would like to create a variable that adds all revenues from all OTHER id 
within the past 14 days (including current date). How can I create the 
"newvar" in the following example?

id      date       revenue  newvar
1    8-Mar-07      1         0
2    15-Mar-07    2         4     (=1+3)
3    15-Mar-07    3         3     (=1+2)
4    22-Mar-07    4         6     (=1+2+3)
5    29-Mar-07    5        15     (=2+3+4+6)
6    29-Mar-07    6        14     (=2+3+4+5)
7    5-Apr-07       7        23     (=4+5+6+8)
8    5-Apr-07       8        22     (=4+5+6+7)
......


Thank you in advance.
Mike.

*
*   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/



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