Date: Mon, 13 Sep 2010 13:00:44 -0400
Reply-To: David Marso <david.marso@GMAIL.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: David Marso <david.marso@GMAIL.COM>
Subject: Re: change multiple category format to multiple dichotomy format
Hi Jan,
See if this solves your problem.
* Declare our new Psy variables *.
NUMERIC none Mood PTSD Anxiety Schiz PD other SUD (F1.0).
* Initialize them to 0.
RECODE Mood TO SUD (ELSE=0).
* VECTOR allows us to "POKE" values based on our source variable values *.
VECTOR Psy=Mood TO SUD.
* Iterate over our source variables *.
DO REPEAT Source = PLPsy1 TO PLPsy6.
+ IF (Source NE 0) Psy(Source)=1.
END REPEAT.
COMPUTE none=(SUM(Mood To SUD) EQ 0).
LIST ID none TO SUD.
ID NONE MOOD PTSD ANXIETY SCHIZ PD OTHER SUD
2.00 0 1 1 0 0 0 1 0
3.00 0 0 0 0 0 0 0 1
7.00 1 0 0 0 0 0 0 0
24.00 0 1 0 0 0 1 1 0
26.00 0 1 1 0 0 0 1 0
27.00 0 0 0 0 0 0 0 1
28.00 0 1 0 0 0 0 1 0
29.00 0 0 0 0 0 0 1 0
30.00 1 0 0 0 0 0 0 0
31.00 0 0 0 0 0 1 0 0
Number of cases read: 10 Number of cases listed: 10
Alternative solution:
NUMERIC none Mood PTSD Anxiety Schiz PD other SUD (F1.0).
* Initialize them to 0.
RECODE Mood TO SUD (ELSE=0).
DO REPEAT V= Mood TO SUD /Value= 1 to 7.
COMPUTE V= ANY(Value,PLPsy1 TO PLPsy6).
END REPEAT.
COMPUTE none=(SUM(Mood To SUD) EQ 0).
HTH, David
=====================
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