```Date: Mon, 20 Jun 2011 10:36:20 +0100 Reply-To: Garry Gelade Sender: "SPSSX(r) Discussion" From: Garry Gelade Subject: Re: Running in total Comments: To: DEBOER In-Reply-To: <1308490459708-4503507.post@n5.nabble.com> Content-Type: text/plain; charset="us-ascii" I'm not exactly sure what you want from looking at your example. However, first of all I'd number your cases by something like: COMPUTE const = 1. COMPUTE casenum =\$casenum. SORT CASES by orgnr year casenum. split file orgnr year. create splitcasenum=csum(const). (casenum is only there to ensure you don't inadvertantly screw up the original case order) Then calculate the maximum number of cases within each split (splitcasemax) using AGGREGATE wih /BREAK = orgnr year using MODE = addvariables and /splitcasemax = MAX(splitcasenum). Then something like: DO IF (splitcasemax - splitcasenum) > 6. COMPUTE desire2 = 0. ELSE. COMPUTE desire2 = desire. END IF. You will then have the last 6 values in each split in desire2, and you can calculate a running sum. split file orgnr year. create cumdesire=csum(desire2). Hope this helps. Garry Gelade -----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of DEBOER Sent: 19 June 2011 14:34 To: SPSSX-L@LISTSERV.UGA.EDU Subject: Running in total Hi all, I have a problem to solve. I want to calculate the running total, but for only the last 6 cases (in points) with respect to orgnr and year. I solved the cumulative variable as follow. sort cases by orgnr year. split file orgnr year. create cumulative=csum(points). execute. The question is how can I create the desire variable so that we only calculate the last six cases in the variable of points? Please see below at the desire variable <

Back to: Top of message | Previous page | Main SPSSX-L page