I'm trying to create a running total in SPSS. Furthermore, I need more than one. My SPSS dataset looks like this (except the running total):
- [x] | [y] | [running total]
- 10 | 1 | 10 (= 0 + 10)
- 20 | 1 | 30 (= 10 + 20)
- 30 | 2 | 30 (= 0 + 30)
- 40 | 2 | 70 (= 30 + 40)
- 50 | 3 | 50 ...
For each value of y (group ID) I want to create a running total. I was able to create a running total over the whole dataset, but that is not what I need. I need something like this:
For y = 1 to 500 compute x = x + lag(x)
Sadly, SPSS isn't able to execute x = x + lag(x) in a loop. I need this done in SPSS syntax (or Python), otherwise I would do it manually in Excel, even though it's a lot of data. I'm pretty frustrated and would really appreciate any help!