LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2005)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 28 Jul 2005 21:52:19 -0400
Reply-To:     Raynald Levesque <rlevesque@videotron.ca>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Raynald Levesque <rlevesque@videotron.ca>
Subject:      Re: Query: Cumulative sum by row
In-Reply-To:  <001301c591f6$1f3dbfd0$d55618d2@spss.com.sg>
Content-type: text/plain; charset=iso-8859-1

Hi

Try this:

DATA LIST LIST / Id Jan Feb Mar Apr May Jun . BEGIN DATA 1 5 5 8 5 15 5 2 5 10 2 5 5 5 3 10 20 10 5 10 10 4 10 30 15 10 20 12 5 10 10 10 10 10 8 6 80 80 90 95 96 100 7 1 2 2 2 2 6 END DATA.

VECTOR subtot(6). COMPUTE subtot(1)=jan. COMPUTE subtot(2)=SUM(jan TO feb). COMPUTE subtot(3)=SUM(jan TO mar). COMPUTE subtot(4)=SUM(jan TO apr). COMPUTE subtot(5)=SUM(jan TO may). COMPUTE subtot(6)=SUM(jan TO jun).

NUMERIC rule1 TO rule3. LOOP #cnt=1 TO 6. - IF subtot(#cnt) GE 20 AND SYSMIS(rule1) rule1=#cnt. - IF subtot(#cnt) GE 35 AND SYSMIS(rule2) rule2=#cnt. - IF subtot(#cnt) GE 50 AND SYSMIS(rule3) rule3=#cnt. END LOOP. EXECUTE.

STRING newrule1 TO newrule3 (A3). RECODE rule1 TO rule3 (1="Jan")(2="Feb") (3="Mar") (4="Apr")(5="May")(6="Jun") INTO newrule1 TO newrule3.

Note that (for ease of seeing what is going on) I have used regular variables for subtot1 TO subtot6 and rule1 TO rule3. Temporary variables could be used instead.

Regards

Raynald Levesque Raynald@spsstools.net Visit my SPSS site: http://www.spsstools.net

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of Tans Family Sent: July 26, 2005 11:24 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Query: Cumulative sum by row

Hi List,

Have a question based on cumulative sum by row. Would anyone care to share some pointers with regards to the problem below? Thanks so much in advance. Appreciate any help.

Regards S

Id Jan Feb Mar Apr May Jun 1 5 5 8 5 15 5 2 5 10 2 5 5 5 3 10 20 10 5 10 10 4 10 30 15 10 20 12 5 10 10 10 10 10 8

Desired output based on rules

Rule 1: if a customer exceed 20, I would like to know which month did he/she exceed Rule 2: if a customer exceed 35, I would like to know which month did he/she exceed Rule 3: if a customer exceed 50, I would like to know which month did he/she exceed

Id Jan Feb Mar Apr May Jun New var rule1 New var rule 2 New var rule 3 1 5 5 5 5 15 5 Apr May Null 2 5 10 2 5 5 5 Apr Null Null 3 10 20 10 5 10 10 Feb Mar May 4 10 5 6 4 20 12 Mar May Jun 5 10 10 10 10 10 8 Feb Apr May


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