|
Hi,
I have multiple response data in the form of multiple categories. Specifically, I have 6 variables (PLPsy1,PLPsy2, PLPsy3, PLPsy4, PLPsy5, PLPsy6). For each variables there are 8 possible values (0 thru 7) which represent none, Mood, PTSD, Anxiety, Schiz, PD, other, and SUD, I want to transform the data to the multiple dichotomies format such that I would have 8 dichotomous (0,1) variables called none, Mood, PTSD, Anxiety, Schiz, PD, other, and SUD. Here is a sample of my data in the current format DATA LIST LIST /id PLPsy1 PLPsy2 PLPsy3 PLPsy4, PLPsy5, PLPsy6. BEGIN DATA. 2 1 2 6 6 0 0 3 7 0 0 0 0 0 7 0 0 0 0 0 0 24 1 5 6 0 0 0 26 1 2 6 6 0 0 27 7 7 0 0 0 0 28 1 6 6 0 0 0 29 6 6 0 0 0 0 30 0 0 0 0 0 0 31 5 0 0 0 0 0 END DATA. LIST. I want to end up with ID none Mood PTSD Anxiety Schiz PD other SUD 2 0 1 1 0 0 0 1 0 3 0 0 0 0 0 0 0 1 7 1 0 0 0 0 0 0 0 Thanks, Jan ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (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 |
|
I think this should work. Untested. This will create 6 new variables per
original PLPsy variable. numeric none.1 to none.6(f2). numeric mood.1 to mood.6(f2). numeric ptsd.1 to ptsd.6(f2). numeric anxiety.1 to anxiety.6(f2). numeric schiz.1 to schiz.6(f2). numeric pd.1 to pd.6(f2). numeric other.1 to other.6(f2). numeric sud.1 to sud.6(f2). do repeat pl = PLPsy1 to PLPsy6 /none = none.1 to none.6 /mood = mood.1 to mood.6 /ptsd = ptsd.1 to psde.6 /anxiety = anxiety.1 to anxiety.6 /schiz = schiz.1 to schiz.6 /pd = pd.1 to pd.6 /other = other.1 to other.6 /sud = sud.1. to sud.6. recode pl (0 = 1)(else = 0) into none. recode pl (1 = 1)(else = 0) into mood. recode pl (2 = 1)(else = 0) into ptsd. recode pl (3 = 1)(else = 0) into anxiety. recode pl (4 = 1)(else = 0) into schiz. recode pl (5 = 1)(else = 0) into pd. recode pl (6 = 1)(else = 0) into other. recode pl (7 = 1)(else = 0) into sud. end repeat. exe. Matthew Pirritano, Ph.D. Research Analyst IV Medical Services Initiative (MSI) Orange County Health Care Agency (714) 568-5648 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of J McClure Sent: Friday, September 10, 2010 2:41 PM To: [hidden email] Subject: change multiple category format to multiple dichotomy format Hi, I have multiple response data in the form of multiple categories. Specifically, I have 6 variables (PLPsy1,PLPsy2, PLPsy3, PLPsy4, PLPsy5, PLPsy6). For each variables there are 8 possible values (0 thru 7) which represent none, Mood, PTSD, Anxiety, Schiz, PD, other, and SUD, I want to transform the data to the multiple dichotomies format such that I would have 8 dichotomous (0,1) variables called none, Mood, PTSD, Anxiety, Schiz, PD, other, and SUD. Here is a sample of my data in the current format DATA LIST LIST /id PLPsy1 PLPsy2 PLPsy3 PLPsy4, PLPsy5, PLPsy6. BEGIN DATA. 2 1 2 6 6 0 0 3 7 0 0 0 0 0 7 0 0 0 0 0 0 24 1 5 6 0 0 0 26 1 2 6 6 0 0 27 7 7 0 0 0 0 28 1 6 6 0 0 0 29 6 6 0 0 0 0 30 0 0 0 0 0 0 31 5 0 0 0 0 0 END DATA. LIST. I want to end up with ID none Mood PTSD Anxiety Schiz PD other SUD 2 0 1 1 0 0 0 1 0 3 0 0 0 0 0 0 0 1 7 1 0 0 0 0 0 0 0 Thanks, Jan ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (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 [hidden email] (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 |
|
Thanks Matthew!
I got the following error message when I tried to run the code. I don't understand 'do repeat' very well so I'm not sure what the error is. Jan >Error # 4516 in column 22. Text: psde.6 >The form VARX TO VARY to refer to a range of variables has been used >incorrectly. It cannot be used when one of VARX or VARY is defined and the >other is not. >Execution of this command stops. On 9/10/2010 3:10 PM, Pirritano, Matthew wrote: > I think this should work. Untested. This will create 6 new variables per > original PLPsy variable. > > numeric none.1 to none.6(f2). > numeric mood.1 to mood.6(f2). > numeric ptsd.1 to ptsd.6(f2). > numeric anxiety.1 to anxiety.6(f2). > numeric schiz.1 to schiz.6(f2). > numeric pd.1 to pd.6(f2). > numeric other.1 to other.6(f2). > numeric sud.1 to sud.6(f2). > > do repeat pl = PLPsy1 to PLPsy6 > /none = none.1 to none.6 > /mood = mood.1 to mood.6 > /ptsd = ptsd.1 to psde.6 > /anxiety = anxiety.1 to anxiety.6 > /schiz = schiz.1 to schiz.6 > /pd = pd.1 to pd.6 > /other = other.1 to other.6 > /sud = sud.1. to sud.6. > > recode pl (0 = 1)(else = 0) into none. > recode pl (1 = 1)(else = 0) into mood. > recode pl (2 = 1)(else = 0) into ptsd. > recode pl (3 = 1)(else = 0) into anxiety. > recode pl (4 = 1)(else = 0) into schiz. > recode pl (5 = 1)(else = 0) into pd. > recode pl (6 = 1)(else = 0) into other. > recode pl (7 = 1)(else = 0) into sud. > end repeat. > exe. > > > Matthew Pirritano, Ph.D. > Research Analyst IV > Medical Services Initiative (MSI) > Orange County Health Care Agency > (714) 568-5648 > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > J McClure > Sent: Friday, September 10, 2010 2:41 PM > To: [hidden email] > Subject: change multiple category format to multiple dichotomy format > > Hi, > I have multiple response data in the form of multiple categories. > Specifically, I have 6 variables (PLPsy1,PLPsy2, PLPsy3, PLPsy4, > PLPsy5, PLPsy6). > For each variables there are 8 possible values (0 thru 7) which > represent none, Mood, PTSD, Anxiety, Schiz, PD, other, and SUD, > I want to transform the data to the multiple dichotomies format such > that I would have 8 dichotomous (0,1) variables called none, Mood, > PTSD, Anxiety, Schiz, PD, other, and SUD. > > Here is a sample of my data in the current format > > DATA LIST LIST /id PLPsy1 PLPsy2 PLPsy3 PLPsy4, PLPsy5, PLPsy6. > BEGIN DATA. > 2 1 2 6 6 0 0 > 3 7 0 0 0 0 0 > 7 0 0 0 0 0 0 > 24 1 5 6 0 0 0 > 26 1 2 6 6 0 0 > 27 7 7 0 0 0 0 > 28 1 6 6 0 0 0 > 29 6 6 0 0 0 0 > 30 0 0 0 0 0 0 > 31 5 0 0 0 0 0 > END DATA. > LIST. > > I want to end up with > ID none Mood PTSD Anxiety Schiz PD other SUD > 2 0 1 1 0 0 0 1 0 > 3 0 0 0 0 0 0 0 1 > 7 1 0 0 0 0 0 0 0 > > Thanks, > Jan > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (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 > [hidden email] (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 [hidden email] (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 |
|
Administrator
|
In reply to this post by J McClure
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 [hidden email] (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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
| Free forum by Nabble | Edit this page |
