Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: running sum


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: running sum
Date   Wed, 4 Aug 2010 16:53:57 +0200

<> 



*************
clear*
inp byte(LINE SUBST POWER) 
1          1          10   
1          2          20   
1          3          15   
1          4           5   
end

bys LINE (SUBST): gen CUM_POW=sum(POWER)

li, noo sepby(LINE)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Maximiliano
Manuel Silva Correa
Gesendet: Mittwoch, 4. August 2010 16:50
An: statalist@hsphsun2.harvard.edu
Betreff: st: running sum

Dear stata people,

Im stuck trying to do a running sum using by.  My problem is like:


Suppose we have serveral power distribution lines (composed of
serveral substations) all around the states. Suppose our variables are
LINE SUBST POWER

I want to generate a variable CUM_POW containing the cummulative sum
of POWER  by LINE SUBST

For instance,

LINE SUBST POWER CUM_POW
1          1          10             10
1          2          20             30
1          3          15             45
1          4           5              50

how goes the sintaxis for that?
*
*   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/


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index