I am looking for a script that will calculate the cumulative sum of say population (based on a presorted table that I have created) as long as the variable of ID is the same. So it might look like
| ID | POP | CUMPOP |
|---|
| 1 | 100 | 100 |
| 1 | 250 | 350 |
| 1 | 150 | 500 |
| 2 | 100 | 100 |
| 2 | 500 | 600 |
| 3 | 150 | 150 |
| 3 | 600 | 750 |
| 3 | 100 | 850 |
| 3 | 150 | 1000 |
this: