Date: Mon, 28 Jan 2008 16:31:45 -0600
Reply-To: Mark Palmberg <mark-palmberg@uiowa.edu>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Mark Palmberg <mark-palmberg@uiowa.edu>
Subject: Re: Syntax to transform numeric variable to date variable (x120)
In-Reply-To: A<001f01c861dd$95582e30$2845cd80@ssw.buffalo.edu>
Content-Type: text/plain; charset="us-ascii"
Gene,
I reorganized my file using KEEP (thanks for the help there) so that it
now looks like:
ID DATE0001 DATE0002 DATE0003...DATE0120 GFTAMT0001 GFTAMT0002
GFTAMT0003...GFTAMT0120
And then ran this syntax again:
do repeat oldvar=DATE0001 TO DATE0120 /newvar=DATE1 TO DATE120.
compute #day=mod(oldvar,100).
compute #year=trunc(oldvar/10000).
compute #month=trunc(mod(oldvar,10000)/100).
compute newvar=date.mdy(#month, #day, #year).
end repeat.
formats DATE1 TO DATE120 (adate10).
This syntax gave me the following output:
do repeat oldvar=DATE0001 TO DATE0120 /newvar=DATE1 TO DATE120.
compute #day=mod(oldvar,100).
compute #year=trunc(oldvar/10000).
compute #month=trunc(mod(oldvar,10000)/100).
compute newvar=date.mdy(#month, #day, #year).
end repeat.
formats DATE1 TO DATE120 (adate10).
EXECUTE.
*>Warning # 613
*>One of the arguments to the DATE function is out of range or is not an
*>integer. The result has been set to the system-missing value.
So you were right in assuming there are probably other issues involved
here.
Thanks!
Mark
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Gene Maguin
Sent: Monday, January 28, 2008 12:43 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: Syntax to transform numeric variable to date variable
(x120)
Mark,
I'm not sure if this is the problem but didn't your original file have
an order of date1, gift1, date2, gift2, etc?
If so and if you did not change the order before the do repeat then that
is a problem because of the way that the 'TO' keyword works. If the
variable order in the file is
A1 d1 a2 d2 a3 d3 a4 d4, a1 to a4 includes d1 d2 d3 as well as a2 and
a3.
There may be other problems but this will be a problem.
You can get around this problem by listing all of the variables to be
used.
Gene Maguin
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD