Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: cum sum in new varaible


From   Max Fotbollen <[email protected]>
To   <[email protected]>
Subject   st: cum sum in new varaible
Date   Fri, 15 Apr 2011 09:30:42 +0200

Hi
I need to have cumulative sum of one certain real number variable set into a new variable. Also I need to be able to list the value of variable in a way one can see all degits.
 
Es:
This my original variable
. list rrs in 1/16
     +-------+
     |   rrs |
     |-------|
  1. |    -1 |
  2. |     0 |
  3. |    -1 |
  4. |     0 |
  5. |     0 |
     |-------|
  6. |  -105 |
  7. |    -5 |
  8. |    38 |
  9. |     1 |
 10. |     0 |
     |-------|
 11. |     0 |
 12. |  -502 |
 13. |   -33 |
 14. |     6 |
 15. |  -146 |
     |-------|
 16. | -5068 |
     +-------+
Actuallu what i need is the cumulative sum of this variable set into one variable. I do not how to do it.(this is my first question).
So what I do is to sum(rrs). This is the result i get
 
 list rrss in 1/16
     +----------+
     |     rrss |
     |----------|
  1. |        1 |
  2. |        1 |
  3. |        2 |
  4. |        2 |
  5. |        2 |
     |----------|
  6. |    11027 |
  7. |    11052 |
  8. |    12496 |
  9. |    12497 |
 10. |    12497 |
     |----------|
 11. |    12497 |
 12. |   264501 |
 13. |   265590 |
 14. |   265626 |
 15. |   286942 |
     |----------|
 16. | 2.60e+07 |

The second question is that i want to see the value of the last obeservation in the same format as in the previous observation.
 
Thanks for comments and suggestion,
 
Max
P.S. I read about cumsum, but i think it is only for ones and zeros  		 	   		  
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index