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 (February 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: Richard Ristow <wrristow@mindspring.com>
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


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