Question of an online survey: What type of cyclist are you (multiple responses are possible)
- recreational cyclist - competitive cyclist - functional cyclist In SPSS this question resulted in three seperate variables: wsb36_0 (0 = not recreational; 1 = recreational) wsb36_1 (0 = not competitive; 1 = competitive) wsb36_2 (0 = not functional; 1 = functional) I would like to recode these variables into one variable labelled "type of cyclist", with the following values: 0 = only recreational (if wsb36_0 = 1 and wsb36_1 = 0 and wsb36_2 = 0) 1 = only competitive (if wsb36_0 = 0 and wsb36_1 = 1 and wsb36_2 = 0) 2 = only functional (if wsb36_0 = 0 and wsb36_1 = 0 and wsb36_2 = 1) 3 = recreational and competitive (if wsb36_0 = 1 and wsb36_1 = 1 and wsb36_2 = 0) 4 = recreational and functional (if wsb36_0 = 1 and wsb36_1 = 0 and wsb36_2 = 1) 5 = competitive and functional (if wsb36_0 = 0 and wsb36_1 = 1 and wsb36_2 = 1) 6 = recreational, competitive and functional (if wsb36_0 = 1 and wsb36_1 = 1 and wsb36_2 = 1) Can anyone help me with how I can do this? Many thanks! |
since you have zero/one
dichotomies there are some readable syntax
approaches. UNTESTED.
These rely on vertical alignment for readability [This post came in just as I was showing someone the virtues of vertical alignment. and avoiding typos by copy-and-paste. So I am accomplishing two things at once, helping the person at my desk and replying to the post.] One approach is to compute a 4 digit variable and label it. no recode necessary. Best viewed in a fixed font. rename vars (wsb36_0 wsb36_1 wsb36_2 = recreational competitive functional). numeric pattern (n3). compute pattern = 100 * recreational + 10 * competitive + 1 * functional . value labels 000 = 'not a rider' 001 = 'functional only' etc. Make a little table of conditions in your editor. paste the line below 8 times. else if not recreational and not competitive and not functional else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. else if not recreational and not competitive and not functional. then replace "not" with 3 blank spaces as needed note the vertical pattern of blanks and NOTs so you have else if not recreational and not competitive and not functional. else if not recreational and not competitive and functional. else if not recreational and competitive and not functional. else if not recreational and competitive and functional. else if recreational and not competitive and not functional. else if recreational and not competitive and functional. else if recreational and competitive and not functional. else if recreational and competitive and functional. then put a first condition in do if nvalid(recreational, competitive, functional) eq 3. and a tail else. end if. paste this line in between. compute TypeOfCyclist = -1. so you have do if nvalid(recreational, competitive, functional) eq 3. else if not recreational and not competitive and not functional. compute TypeOfCyclist = -1. else if not recreational and not competitive and functional. compute TypeOfCyclist = -1. else if not recreational and competitive and not functional. compute TypeOfCyclist = -1. else if not recreational and competitive and functional. compute TypeOfCyclist = -1. else if recreational and not competitive and not functional. compute TypeOfCyclist = -1. else if recreational and not competitive and functional. compute TypeOfCyclist = -1. else if recreational and competitive and not functional. compute TypeOfCyclist = -1. else if recreational and competitive and functional. compute TypeOfCyclist = -1. else. compute TypeOfCyclist = -1. end if. Then go down the column and replace -1 with " 0" , " 1" etc do if nvalid(recreational, competitive, functional) eq 3. else if not recreational and not competitive and not functional. compute TypeOfCyclist = 0. else if not recreational and not competitive and functional. compute TypeOfCyclist = 1. else if not recreational and competitive and not functional. compute TypeOfCyclist = 2. else if not recreational and competitive and functional. compute TypeOfCyclist = 3. else if recreational and not competitive and not functional. compute TypeOfCyclist = 4. else if recreational and not competitive and functional. compute TypeOfCyclist = 5. else if recreational and competitive and not functional. compute TypeOfCyclist = 6. else if recreational and competitive and functional. compute TypeOfCyclist = 7. else. compute TypeOfCyclist = -1. end if. eyeball the syntax for vertical alignment. note the patterns of nots and blanks first column 4 nots 4 blanks second column 2 nots 2 blanks. third column alternates nots and blanks. note equal signs align note assigned values align Art Kendall Social Research ConsultantsOn 5/17/2013 6:07 AM, ingederom [via SPSSX Discussion] wrote: Question of an online survey: What type of cyclist are you (multiple responses are possible)
Art Kendall
Social Research Consultants |
In reply to this post by ingederom
One way is this. There are others, I'm sure.
Compute pattern=100*wsb36_0+10*wsb36_1+wsb36_2 . Recode pattern(100=0)(10=1)(1=2)(110=3)(101=4)(11=5)(111=6)(else=9) into type. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ingederom Sent: Friday, May 17, 2013 6:08 AM To: [hidden email] Subject: Recoding multiple variables into one variable using syntax Question of an online survey: What type of cyclist are you (multiple responses are possible) - recreational cyclist - competitive cyclist - functional cyclist In SPSS this question resulted in three seperate variables: wsb36_0 (0 = not recreational; 1 = recreational) wsb36_1 (0 = not competitive; 1 = competitive) wsb36_2 (0 = not functional; 1 = functional) I would like to recode these variables into one variable labelled "type of cyclist", with the following values: 0 = only recreational (if wsb36_0 = 1 and wsb36_1 = 0 and wsb36_2 = 0) 1 = only competitive (if wsb36_0 = 0 and wsb36_1 = 1 and wsb36_2 = 0) 2 = only functional (if wsb36_0 = 0 and wsb36_1 = 0 and wsb36_2 = 1) 3 = recreational and competitive (if wsb36_0 = 1 and wsb36_1 = 1 and wsb36_2 = 0) 4 = recreational and functional (if wsb36_0 = 1 and wsb36_1 = 0 and wsb36_2 = 1) 5 = competitive and functional (if wsb36_0 = 0 and wsb36_1 = 1 and wsb36_2 = 1) 6 = recreational, competitive and functional (if wsb36_0 = 1 and wsb36_1 = 1 and wsb36_2 = 1) Can anyone help me with how I can do this? Many thanks! -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-multiple-variables-into-one-variable-using-syntax-tp5720297.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 ingederom
DATA LIST FREE / r c f x.
begin data 1 0 0 0 0 1 0 1 0 0 1 2 1 1 0 3 1 0 1 4 0 1 1 5 1 1 1 6 end data. COMPUTE Y=RND(-1.5 + 1.625*r + 2.625* c + 3.625 * f). FORMAT ALL (F1.0). LIST. r c f x Y 1 0 0 0 0 0 1 0 1 1 0 0 1 2 2 1 1 0 3 3 1 0 1 4 4 0 1 1 5 5 1 1 1 6 6 Number of cases read: 7 Number of cases listed: 7
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?" |
Greetings,
Thank you for your message. I will be out of the office with limited internet access and will return on Tuesday, May 28th. I will reply to your email as soon as possible when I return if you seek a reply. If you require immediate assistance, please contact E.J. Keeley, Director of Institutional Assessment & Research, at [hidden email]<mailto:[hidden email]> or x2223. Thanks, -Pat ===================== 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 |
Free forum by Nabble | Edit this page |