Date: Thu, 21 Jun 2007 14:04:14 -0500
Reply-To: "Marks, Jim" <Jim.Marks@lodgenet.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Marks, Jim" <Jim.Marks@lodgenet.com>
Subject: Re: Converting scale value into binary columns
Content-Type: text/plain; charset="US-ASCII"
Here is a solution-- I assume you have multiple contacts per row.
*** sample data.
DATA LIST LIST (",") /id (f8.0) contact_1 TO contact_4 (4moyr8).
1 , JAN 2002, MAY 2002, JUL 2002, AUG 2002
2 , MAR 2003, APR 2003,
3 , FEB 2002, JUN 2002, OCT 2002, DEC 2002
**** create a variable for each contact date with the month of the
x = contact_1 to contact_4
/y = cmth_1 to cmth_4.
COMPUTE y = xdate.month(x).
*** loop thru the contact months and create a month variable mth_1 =
VECTOR cm = cmth_1 TO cmth_4.
LOOP #j = 1 TO 4.
LOOP #i = 1 TO 12.
IF cm(#j) = (#i) mth_(#i) = 1.
RECODE mth_1 to mth_12 (sysmis = 0).
The loop for #j and the do repeat should match the nbr of contacts per
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Thursday, June 21, 2007 9:29 AM
Subject: Converting scale value into binary columns
It would be great if anyone could help me out with the following:
I have a series of contact dates such as
Jan02 May02 July02 Aug02
I would eventually like to convert this into binary coding
month-by-month such that if a contact occurred in a given month the
value is 1 and otherwise it is 0. I calculated the difference between
the contact dates (in months) such that I have the following:
datediff1 datediff2 datediff3 datediff4
1 4 2 1
I would like to conver this into a new series of columns with (n-1)
zeroes in between ones such that the above would become:
1 0 0 0 1 0 1 1
This would reflect the months January to August, with a 1 for a contact
and a 0 for no contact.
Again, if anyone can help me out, I would appreciate it.