Cumulative Sum (WITHOUT AGGREGATE AND CREATE)

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Nienkedejong
Posts: 1
Joined: Mon Nov 04, 2013 3:53 pm

Cumulative Sum (WITHOUT AGGREGATE AND CREATE)

Postby Nienkedejong » Mon Nov 04, 2013 4:02 pm

Dear all,

We need to create a cumulative sum over different casenumbers. However, given that we have a really huge dataset, we would like to avoid using an aggregate or create command.

Suppose we have 4 case numbers:
Case X
1 2
2 3
3 1
4 2

What we have done already is the following:
Case X Xsum
1 2 2
2 3 5
3 1 6
4 2 8

So, in a sense we already have a cumulative sum with using a DO IF statement and using lags. However, we now want to have the number 8 at all 4 cases. So we want:

Case X Xsum Xsum2
1 2 2 8
2 3 5 8
3 1 6 8
4 2 8 8

We already looked at taking leads, but this again needs a create function (or can we do it with a compute function???) and we also thought about imputing missing values, but this also did not work out yet.

hopefully someone can help us out?
Many thanks!

Nienke
pythonforspss.org
Posts: 116
Joined: Sat Oct 06, 2012 6:21 am

Re: Cumulative Sum (WITHOUT AGGREGATE AND CREATE)

Postby pythonforspss.org » Mon Nov 04, 2013 7:58 pm

Try

Code: Select all

aggregate outfile = * mode addvariables
/xsum2 = max(xsum).
Kind regards,

Ruben Geert van den Berg
http://www.spss-tutorials.com

Who is online

Users browsing this forum: No registered users and 4 guests

cron