I inherited a dataset composed of 300 cases.
There are 3 classes of respondents and a grouping variable named "class" that is coded with a value of 1, 2 or 3 for each case. Var11 contains coded responses to a question that was only answered by class 1 respondents. It contains 90 coded responses from the 90 class 1 respondents and 210 system missing values. Var21 contains coded responses to a question that was only answered by class 2 respondents. It contains 40 coded responses from the 40 class 2 respondents and 260 system missing values. Var34 contains coded responses to a question that was only answered by class 3 respondents. It contains 170 coded responses from the 170 class 3 respondents and 130 system missing values. How do I write the syntax to combine the responses to var11, var21 and var34 into a single variable named var44? (If I just recode var44 3 times I wind up with the 170 class 3 responses in var44 and system missing values for everybody else). |
Jim,
This should do it. If (class eq 1) v44=v11. If (class eq 2) v44=v21. If (class eq 3) v44=v34. Gene Maguin |
In reply to this post by Jim Moffitt
Try this
Recode Var11 Var21 Var34 (sysmis=0). Compute Var44=Var11+Var21+Var34. Recode Var11 Var21 Var34 (0=sysmis). Exe. Just to make you don't have any 0 in Var11 Var21 Var34 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Moffitt Sent: Thursday, June 29, 2006 4:49 PM To: [hidden email] Subject: Stacking Vartibles Into a New Variable I inherited a dataset composed of 300 cases. There are 3 classes of respondents and a grouping variable named "class" that is coded with a value of 1, 2 or 3 for each case. Var11 contains coded responses to a question that was only answered by class 1 respondents. It contains 90 coded responses from the 90 class 1 respondents and 210 system missing values. Var21 contains coded responses to a question that was only answered by class 2 respondents. It contains 40 coded responses from the 40 class 2 respondents and 260 system missing values. Var34 contains coded responses to a question that was only answered by class 3 respondents. It contains 170 coded responses from the 170 class 3 respondents and 130 system missing values. How do I write the syntax to combine the responses to var11, var21 and var34 into a single variable named var44? (If I just recode var44 3 times I wind up with the 170 class 3 responses in var44 and system missing values for everybody else). |
In reply to this post by Maguin, Eugene
Thanks, Gene. This is exactly what I needed.
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin Sent: Thursday, June 29, 2006 3:54 PM To: [hidden email] Subject: Re: Stacking Vartibles Into a New Variable Jim, This should do it. If (class eq 1) v44=v11. If (class eq 2) v44=v21. If (class eq 3) v44=v34. Gene Maguin |
In reply to this post by Siraj Ur-rehman
Thanks, Siraj, but maybe my description wasn't clear. Your code would
replace all the system missing values with a zero. I'd like to preserve the system missing values where they are appropriate. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Siraj Ur-rehman Sent: Thursday, June 29, 2006 3:58 PM To: [hidden email] Subject: Re: Stacking Vartibles Into a New Variable Try this Recode Var11 Var21 Var34 (sysmis=0). Compute Var44=Var11+Var21+Var34. Recode Var11 Var21 Var34 (0=sysmis). Exe. Just to make you don't have any 0 in Var11 Var21 Var34 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Moffitt Sent: Thursday, June 29, 2006 4:49 PM To: [hidden email] Subject: Stacking Vartibles Into a New Variable I inherited a dataset composed of 300 cases. There are 3 classes of respondents and a grouping variable named "class" that is coded with a value of 1, 2 or 3 for each case. Var11 contains coded responses to a question that was only answered by class 1 respondents. It contains 90 coded responses from the 90 class 1 respondents and 210 system missing values. Var21 contains coded responses to a question that was only answered by class 2 respondents. It contains 40 coded responses from the 40 class 2 respondents and 260 system missing values. Var34 contains coded responses to a question that was only answered by class 3 respondents. It contains 170 coded responses from the 170 class 3 respondents and 130 system missing values. How do I write the syntax to combine the responses to var11, var21 and var34 into a single variable named var44? (If I just recode var44 3 times I wind up with the 170 class 3 responses in var44 and system missing values for everybody else). |
In reply to this post by Maguin, Eugene
At 04:54 PM 6/29/2006, Gene Maguin wrote:
>This should do it. > >If (class eq 1) v44=v11. >If (class eq 2) v44=v21. >If (class eq 3) v44=v34. It should, indeed. I'd say, that's the way to do it. But, just to be 'cute', there's COMPUTE V44 = MAX(v11,v21,v34). Now, if a value is filled in that shouldn't be, say v34 has a value for a class-1 respondent, Gene's code handles it about as reasonably as possible, and mine won't. But, hey, coding tricks are fun. -Onward, Richard |
Free forum by Nabble | Edit this page |