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 variable
From
Max Fotbollen <[email protected]>
To
<[email protected]>
Subject
st: cum sum in new variable
Date
Fri, 15 Apr 2011 10:04:04 +0200
Sorry, in my previous mail I inserted a wrong column in my ex. Here is the correct one:
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.
Ex:
This my original variable
list rrs in 1/16
+----------+
| rrs |
|----------|
1. | 1 |
2. | 0 |
3. | 1 |
4. | 0 |
5. | 0 |
|----------|
6. | 11025 |
7. | 25 |
8. | 1444 |
9. | 1 |
10. | 0 |
|----------|
11. | 0 |
12. | 252004 |
13. | 1089 |
14. | 36 |
15. | 21316 |
|----------|
16. | 2.57e+07 |
Actually 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 observation 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/