Date: Thu, 13 Jun 2002 19:57:11 -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: Transformation question
In-Reply-To: <20020613103607.14457.qmail@mail.com>
Content-Type: text/plain; charset="US-ASCII"
Hi
This is one way:
DATA LIST LIST /datum(DATE11) category(F8.0) h1 TO h4(4F8.0).
BEGIN DATA.
1/1/99 1 18 23 13 34
1/1/99 2 531 1026 887 865
1/1/99 3 0 2 0 4
1/1/99 4 0 1 0 2
1/1/99 1 4 11 14 16
1/1/99 2 323 788 805 756
1/1/99 3 1 2 0 0
1/1/99 4 1 0 0 2
1/2/99 1 10 6 3 6
1/2/99 2 427 281 248 254
1/2/99 3 13 26 20 18
1/2/99 4 9 15 22 24
1/2/99 1 16 6 5 6
1/2/99 2 475 312 258 605
1/2/99 3 6 4 3 4
1/2/99 4 1 3 0 2
31/12/99 1 22 12 12 3
31/12/99 2 2 0 15 7
31/12/99 3 134 251 343 236
31/12/99 4 135 125 451 535
31/12/99 1 12 32 14 10
31/12/99 2 13 43 30 41
31/12/99 3 30 43 54 21
31/12/99 4 210 240 167 231
END DATA.
LIST.
VARIABLE WIDTH datum(11).
SORT CASES BY datum category.
AGGREGATE
/OUTFILE=*
/PRESORTED
/BREAK=datum category
/h1 TO h4= SUM(h1 TO h4).
VECTOR h=h1 TO h4.
LOOP hour1=1 TO 4.
COMPUTE totalamt=h(hour1).
XSAVE OUTFILE='c:\temp\data.sav' /KEEP=datum category hour1 totalamt.
END LOOP.
EXECUTE.
GET FILE='c:\temp\data.sav'.
FORMATS hour1 totalamt(F8.0).
Note that you will have to replace all 4's by 24's in the above syntax.
HTH
Raynald Levesque rlevesque@videotron.ca
Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Tran Bac
Sent: June 13, 2002 6:36 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Transformation question
Hi Listers,and thanh you Raynald so much.
Last time I had above data set included 26 variables and I wanted to make
another file that has ony 3 variables. I have used above syntax and
everything is perfect. Now I have a data set looks like this (26 variables):
Datum Category H1 H2 H3......H24
1/1/99 1 18 23 13.......34
1/1/99 2 531 1026 887......865
1/1/99 3 0 2 0 ......4
1/1/99 4 0 1 0 ......2
1/1/99 1 4 11 14 ......16
1/1/99 2 323 788 805......756
1/1/99 3 1 2 0 ......0
1/1/99 4 1 0 0 ......2
1/2/99 1 10 6 3 ......6
1/2/99 2 427 281 248......254
1/2/99 3 13 26 20 ......18
1/2/99 4 9 15 22 ......24
1/2/99 1 16 6 5 ......6
1/2/99 2 475 312 258......605
1/2/99 3 6 4 3 ......4
1/2/99 4 1 3 0 ......2
. . . . . . . .
. . . . . . . .
31/12/99 1 22 12 12 .....3
31/12/99 2 2 0 15 .....7
31/12/99 3 134 251 343.....236
31/12/99 4 135 125 451.....535
31/12/99 1 12 32 14 .....10
31/12/99 2 13 43 30 .....41
31/12/99 3 30 43 54 .....21
31/12/99 4 210 240 167.....231
I want to change it like this (4 variables):
Date Category Hour TotalAmt
1/1/99 1 1 22(18+4)
1/1/99 1 2 34(23+11)
1/1/99 1 3 27(13+14)
. . . .
. . . .
1/1/99 1 24 50(34+16)
1/1/99 2 1 844(521+323)
. . . .
. . . .
1/1/99 2 24 1621(865+756)
1/1/99 3 1 1(0+1)
. . . .
1/1/99 3 24 4(4+0)
1/1/99 4 1 1(0+1)
. . . .
1/1/99 4 24 4(2+2)
. . . .
. . . .
31/12/99 4 24 766(535+231)
I think,this problem is not so difficult, but I have just used SPSS for
short time, so I dont know how to use syntax command. I would be grateful if
anyone could help me to solve this problem.
Thanks a lot,
Tran Bac
<snip>