Date: Thu, 21 Feb 2008 20:13:49 -0600
Reply-To: "Peck, Jon" <peck@spss.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Peck, Jon" <peck@spss.com>
Subject: Re: seeking help with date variables
In-Reply-To: A<7.0.1.0.2.20080221190005.03c7f278@mindspring.com>
Content-Type: text/plain; charset="utf-8"
As Richard says,
RECODE works for all variables, though it can be awkward for dates.
However, one of our Python supplementary modules handles date notation for recodes. It also creates value labels for the recoded variable automatically. Here is an example. The code below recodes the date variable bdate (in employee data.sav) into bdaterecode. It takes a dictionary of values to recode. So, for example, the date
1952-02-03 is recoded into the value 100.
The generate line executes the commands, but it also returns the syntax for the Recode and for generating value labels for the recoded data in case that is wanted for other reasons.
begin program.
import spss, specialtransforms
rec = specialtransforms.Recode("bdaterecode", "bdate",
{'1952-02-03': 100, '1958-05-23':200}, inputtype='D', elserc=300)
syntax = rec.generate(execute=True)
print syntax
end program.
The syntax printed would be
NUMERIC bdaterecode (F8.0).
RECODE bdate (11654150400=100) (11852956800=200) (ELSE=300) INTO bdaterecode.
VALUE LABELS bdaterecode 200 "1958-05-23" 100 "1952-02-03".
This requires at least SPSS 14.0.1, the Python plugin, and the specialtransforms module, the latter two from SPSS Developer Central (www.spss.com/devcentral).
Regards,
Jon Peck
=====================
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
|