|
Hi Listers,
I am running V18 (but not Python) I have data from multiple responses which are entered in SPSS as a string variable - respondents were asked to tick all that apply and there were 7 options. The question asked young people where they hung out in the local area - so 1 = own home; 2 = friends home; 3 = outside; 4 = online; etc. Data is in the form: 1,2,4,6 2,3,7 1,4,6,7 1,2,3,4,5,6,7 4,6 Etc. They are always in order, but do not necessarily start at 1. I had a look in Raynald's programming book and tried to adapt the syntax he uses in an example about splitting telephone numbers into component parts - but ended up getting stuck. Also had a look at archives but not the easiest to search What I want is to create seven new dummy variables (v1 to v7) where the variables correspond to the seven possible options I will then use the multiple response option to analyze (thanks to John Hall for assistance there) Thanks in advance Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA Research Fellow School of Education University of Glasgow 0044+141-330-4699 ===================== 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
|
data list list / stringvar (a15). begin data "1,2,4,6" "2,3,7" "1,4,6,7" "1,2,3,4,5,6,7" "4,6" end data. numeric r1 to r7 (f1.0). do repeat r = r1 to r7 / #i = 1 to 7. - compute r = char.index(stringvar,string(#i,f1)) GT 0. end repeat. list.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
Administrator
|
In reply to this post by Muir Houston-2
On Thu, 7 Oct 2010 07:42:33 -0700, Bruce Weaver <[hidden email]>
wrote: >Muir Houston-2 wrote: >> >> Hi Listers, >> I am running V18 (but not Python) >> >> I have data from multiple responses which are entered in SPSS as a >> string variable - respondents were asked to tick all that apply and >> there were 7 options. The question asked young people where they hung >> out in the local area - so 1 = own home; 2 = friends home; 3 = outside; >> 4 = online; etc. >> >> Data is in the form: >> 1,2,4,6 >> 2,3,7 >> 1,4,6,7 >> 1,2,3,4,5,6,7 >> 4,6 >> Etc. >> >> They are always in order, but do not necessarily start at 1. >> >> I had a look in Raynald's programming book and tried to adapt the syntax >> he uses in an example about splitting telephone numbers into component >> parts - but ended up getting stuck. Also had a look at archives but not >> the easiest to search >> >> What I want is to create seven new dummy variables (v1 to v7) where the >> variables correspond to the seven possible options >> >> I will then use the multiple response option to analyze (thanks to John >> Hall for assistance there) >> >> Thanks in advance >> > >data list list / stringvar (a15). >begin data >"1,2,4,6" >"2,3,7" >"1,4,6,7" >"1,2,3,4,5,6,7" >"4,6" >end data. > >numeric r1 to r7 (f1.0). >do repeat r = r1 to r7 / #i = 1 to 7. >- compute r = char.index(stringvar,string(#i,f1)) GT 0. >end repeat. >list. > > > >----- >-- >Bruce Weaver >[hidden email] >http://sites.google.com/a/lakeheadu.ca/bweaver/ > >"When all else fails, RTFM." > > Here's a slightly different version using a VECTOR. --- VECTOR V(7). LOOP #=1 to 7. + COMPUTE V(#)=CHAR.INDEX(strvar,string(#,f1)) GT 0. END LOOP. ===================== 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 |
