Hi all,
Here is my dilemma. I have data from a survey that used ranked responses. The respondents typed in what they thought was important and then ranked their own responses from 1-5. When the data was returned to me it created 10 variables. Variable 1 is a numerical rank and Variable 2 is their typed responses corresponding to that rank and so on. The rank score in Variable 1, numerical, from 1-5. See the following. I'm making up this example data, in the real data the text responses can be anything with over 100 characters. Var1 Var2 Var 3 Var4 2 pizza 5 Milk 1 burgers 1 Vegies 5 carrots 3 Steak 4 squash 2 Toast 3 M&Ms 4 Waffles I really want to analyze the ranked responses corresponding to their appropriate rank. Thus, RANKResponse1 RANKResponse2 RANKResponse3 Burgers pizza M&Ms Vegies toast Steak I started by concatenating the rank and the response (see below) thinking I can then split them to look like the RANKResponse variables but that is where I'm lost. And I think there must better way to do this. NewVar 2pizza 1burger Thanks Zana ===================== 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
|
This should help.
DATA LIST LIST /Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100). BEGIN DATA 2 pizza 5 Milk 1 burgers 1 Vegies 5 carrots 3 Steak 4 squash 2 Toast 3 M&Ms 4 Waffles END DATA. VECTOR Result_a(5,A100) / Result_b(5,A100). COMPUTE Result_a(Var1)=Var2. COMPUTE Result_b(Var3)=Var4. AGGREGATE OUTFILE * / Result1_1 TO Result1_5 Result2_1 TO Result2_5 = MAX(Result_a1 TO Result_a5 Result_b1 TO Result_b5). LIST.
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?" |
In reply to this post by Zana Dael
David,
I'm sorry, I didn't frame my question correctly. Let me start over. DATA LIST LIST /ID (F2) Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100) Var5 (F1) Var6 (A100) Var7 (F1) Var8 (A100). BEGIN DATA 15 2 pizza 3 Milk 4 hotdogs 1 ice cream 16 1 burgers 4 Vegies 3 pizza 2 M&Ms 17 4 carrots 3 Steak 1 squash 2 Toast 18 1 squash 2 Eggs 4 Waffles 3 peas END DATA. I want a final file that looks like this. With the rank score (1-4) becoming the new variables and each respondent answer corresponding to the correct rank score/variable. ID Rank1 Rank2 Rank3 Rank4 15 ice cream pizza milk hotdogs 16 burgers M&Ms pizza Vegies 17 squash toast steak carrots 18 squash Eggs peas waffles I'm hoping this can be done in syntax, or I have to rearrange the answers manually. Also, I don't know how to use python, so I'm limited to syntax. Zana On Thu, 15 Aug 2013 09:59:03 -0700, David Marso <[hidden email]> wrote: >This should help. >DATA LIST LIST /Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100). >BEGIN DATA >2 pizza 5 Milk >1 burgers 1 Vegies >5 carrots 3 Steak >4 squash 2 Toast >3 M&Ms 4 Waffles >END DATA. >VECTOR Result_a(5,A100) / Result_b(5,A100). >COMPUTE Result_a(Var1)=Var2. >COMPUTE Result_b(Var3)=Var4. >AGGREGATE OUTFILE * > / Result1_1 TO Result1_5 Result2_1 TO Result2_5 > = MAX(Result_a1 TO Result_a5 Result_b1 TO Result_b5). >LIST. > > > > >----- >Please reply to the list and not to my personal email. >Those desiring my consulting or training services please feel free to email >--- >"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?" >-- >View this message in context: http://spssx- discussion.1045642.n5.nabble.com/Formatting-Ranked-Responses- tp5721585p5721587.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
|
Of course it can be done in Syntax (with 3 lines).
DATA LIST LIST /ID (F2) Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100) Var5 (F1) Var6 (A100) Var7 (F1) Var8 (A100). BEGIN DATA 15 2 pizza 3 Milk 4 hotdogs 1 icecream 16 1 burgers 4 Vegies 3 pizza 2 M&Ms 17 4 carrots 3 Steak 1 squash 2 Toast 18 1 squash 2 Eggs 4 Waffles 3 peas END DATA. VARSTOCASES / MAKE Index FROM Var1 Var3 Var5 Var7 / MAKE strVar FROM Var2 Var4 Var6 Var8 / KEEP ID. SORT CASES BY ID Index. CASESTOVARS /ID=ID /INDEX=Index /GROUPBY=VARIABLE.
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?" |
In reply to this post by Zana Dael
Awesome. You can't believe the acrobatics, hair pulling and head smacking I
was doing to get it to work. 3 Lines. Amazing. Zana On Thu, 15 Aug 2013 11:01:58 -0700, David Marso <[hidden email]> wrote: >Of course it can be done in Syntax (with 3 lines). > >DATA LIST LIST /ID (F2) Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100) Var5 >(F1) Var6 (A100) Var7 (F1) Var8 (A100). >BEGIN DATA >15 2 pizza 3 Milk 4 hotdogs 1 icecream >16 1 burgers 4 Vegies 3 pizza 2 M&Ms >17 4 carrots 3 Steak 1 squash 2 Toast >18 1 squash 2 Eggs 4 Waffles 3 peas >END DATA. >VARSTOCASES > / MAKE Index FROM Var1 Var3 Var5 Var7 > / MAKE strVar FROM Var2 Var4 Var6 Var8 > / KEEP ID. >SORT CASES BY ID Index. >CASESTOVARS > /ID=ID > /INDEX=Index > /GROUPBY=VARIABLE. > > >Zd Gibbs wrote >> David, >> >> I'm sorry, I didn't frame my question correctly. Let me start over. >> >> DATA LIST LIST /ID (F2) Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100) Var5 >> (F1) Var6 (A100) Var7 (F1) Var8 (A100). >> BEGIN DATA >> 15 2 pizza 3 Milk 4 hotdogs 1 ice cream >> 16 1 burgers 4 Vegies 3 pizza 2 M&Ms >> 17 4 carrots 3 Steak 1 squash 2 Toast >> 18 1 squash 2 Eggs 4 Waffles 3 peas >> END DATA. >> >> >> I want a final file that looks like this. With the rank score (1-4) >> becoming >> the new variables and each respondent answer corresponding to the correct >> rank score/variable. >> >> ID Rank1 Rank2 Rank3 Rank4 >> 15 ice cream pizza milk hotdogs >> 16 burgers M&Ms pizza Vegies >> 17 squash toast steak carrots >> 18 squash Eggs peas waffles >> >> I'm hoping this can be done in syntax, or I have to rearrange the answers >> manually. Also, I don't know how to use python, so I'm limited to syntax. >> >> Zana >> >> On Thu, 15 Aug 2013 09:59:03 -0700, David Marso < > >> david.marso@ > >> > >> wrote: >> >>>This should help. >>>DATA LIST LIST /Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100). >>>BEGIN DATA >>>2 pizza 5 Milk >>>1 burgers 1 Vegies >>>5 carrots 3 Steak >>>4 squash 2 Toast >>>3 M&Ms 4 Waffles >>>END DATA. >>>VECTOR Result_a(5,A100) / Result_b(5,A100). >>>COMPUTE Result_a(Var1)=Var2. >>>COMPUTE Result_b(Var3)=Var4. >>>AGGREGATE OUTFILE * >>> / Result1_1 TO Result1_5 Result2_1 TO Result2_5 >>> = MAX(Result_a1 TO Result_a5 Result_b1 TO Result_b5). >>>LIST. >>> >>> >>> >>> >>>----- >>>Please reply to the list and not to my personal email. >>>Those desiring my consulting or training services please feel free to >> me. >>>--- >>>"Nolite dare sanctum canibus neque mittatis margaritas vestras ante >> ne forte conculcent eas pedibus suis." >>>Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in >> abyssum?" >>>-- >>>View this message in context: http://spssx- >> discussion.1045642.n5.nabble.com/Formatting-Ranked-Responses- >> tp5721585p5721587.html >>>Sent from the SPSSX Discussion mailing list archive at Nabble.com. >>> >>>===================== >>>To manage your subscription to SPSSX-L, send a message to >>> > >> LISTSERV@.UGA > >> (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 > >> LISTSERV@.UGA > >> (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 >--- >"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?" >-- >View this message in context: http://spssx- discussion.1045642.n5.nabble.com/Formatting-Ranked-Responses- tp5721585p5721590.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 |
In reply to this post by David Marso
You can do it without reshaping and sorting as well. 4 lines though :(
************************************. DATA LIST LIST /ID (F2) Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100) Var5 (F1) Var6 (A100) Var7 (F1) Var8 (A100). BEGIN DATA 15 2 pizza 3 Milk 4 hotdogs 1 icecream 16 1 burgers 4 Vegies 3 pizza 2 M&Ms 17 4 carrots 3 Steak 1 squash 2 Toast 18 1 squash 2 Eggs 4 Waffles 3 peas END DATA. vector Rank(4A100). do repeat Num = Var1 Var3 Var5 Var7 /Str = Var2 Var4 Var6 Var8. compute Rank(Num) = Str. end repeat. ************************************. Make sure you don't have people with duplicate ranks if you use this! |
In reply to this post by Zana Dael
4 lines but one file - I do tend to lose them.
Thanks to you both. This has been great help. Zana. On Thu, 15 Aug 2013 11:51:11 -0700, Andy W <[hidden email]> wrote: >You can do it without reshaping and sorting as well. 4 lines though :( > >************************************. >DATA LIST LIST /ID (F2) Var1 (F1) Var2 (A100) Var3 (F1) Var4 (A100) Var5 >(F1) Var6 (A100) Var7 (F1) Var8 (A100). >BEGIN DATA >15 2 pizza 3 Milk 4 hotdogs 1 icecream >16 1 burgers 4 Vegies 3 pizza 2 M&Ms >17 4 carrots 3 Steak 1 squash 2 Toast >18 1 squash 2 Eggs 4 Waffles 3 peas >END DATA. >vector Rank(4A100). >do repeat Num = Var1 Var3 Var5 Var7 /Str = Var2 Var4 Var6 Var8. > compute Rank(Num) = Str. >end repeat. >************************************. > >Make sure you don't have people with duplicate ranks if you use this! > > > >----- >Andy W >[hidden email] >http://andrewpwheeler.wordpress.com/ >-- >View this message in context: http://spssx- tp5721585p5721593.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 |
Free forum by Nabble | Edit this page |