Hi,
I have the following data. In this example respondents will see two set of ads (each set containing 3 ads). The have to choose 2. There are 4 versions. Each version with a different set of ads. This are the responses: DATA LIST /id 1 version 3 att1_1 5-6 (A) att2_1 8-9 (A) att3_1 11-12 (A) q3aa_1 14-15 (A) q3ab_1 17-18 (A) att1_2 20-21 (A) att2_2 23-24 (A) att3_2 26-27 (A) q3aa_2 29-30 (A) q3ab_2 32-33 (A). BEGIN DATA 1 1 a1 a2 a3 a1 a2 z3 z8 a2 z8 z3 2 1 a1 a2 a3 a2 a3 z3 z8 a2 a2 z8 3 2 b3 b2 b8 b8 b2 t3 t7 c2 t3 c2 4 3 b3 a2 b2 b3 b2 r2 b3 a2 a2 b3 5 4 c3 c9 c1 c1 c9 c9 a1 a8 c9 a1 6 1 a1 a2 a3 a2 a3 a1 a2 a3 a3 a1 7 4 c3 c9 c1 c3 c1 c9 a1 a8 a8 a1 END DATA. I need to transpose the data, but I'm really struggling. I have tried different ways with the aggregate command but I can't get what I want. I would like to list the set of ads and then next to it the answers of each respondent. I would like to end up with something like this: DATA LIST /newid 1 att_1 3-4 (A) att_2 6-7 (A) att_3 9-10 (A) answer11 12-13 (A) answer12 15-16 (A) answer21 18-19 (A) answer22 21-22(A) answer31 24-25 (A) answer32 27-28(A) . BEGIN DATA 1 a1 a2 a3 a1 a2 a2 a3 a2 a3 2 z3 z8 a2 z8 z3 a2 z8 a3 a1 3 b3 b2 b8 b8 b2 4 t3 t7 c2 t3 c2 5 b3 a2 b2 b3 b2 6 r2 b3 a2 a2 b3 7 c3 c9 c1 c1 c9 c3 c1 8 c9 a1 a8 c9 a1 a8 a1 END DATA. I hope it makes sense. Please, let me know if you need further information. The real dataset has only 4 versions with 20 set of ads each. Any help will be really appreciate it. Thanks.
mils
|
Administrator
|
"I hope it makes sense. "
NO! Absolutely NONE since you have not explained the relationship between the two tables. I have NO idea what rules the mapping between the 2 examples and am not going to spend a lot of time trying to read your mind. It is your task to provide adequate detail and not set us up a puzzle of how the two are related. you need to back up and clearly explain what you are thinking. --
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 mils
Hi,
Each version has a different set: version 1 - 2 sets of ads a1 a2 a3 z3 z8 a2 version 2 - 2 sets of ads b3 b2 b8 t3 t7 c2 version 3 - 2 sets of ads b3 a2 b2 r2 b3 a2 version 4 - 2 sets of ads c3 c9 c1 c9 a1 a8 Each person saw one version In each version, each person saw two sets of ads (6 ads total). for each set, each respondent choose two ads that they especially like/hate. Version are shonw randomly. The first "dataset" shows the format of the data collected. The second "dataset" is the format i would like to have. Please, find below a description. newid: is the number of sets, in this case 8. att_1,att_2,att_3: list the adds of each set (3 per set) answer11,answer12 : list for each set the two ads (like,hate) choosen first answer21,answer22: list for each set the two ads (like,hate) choosen second answer31,answer32: list for each set the two ads (like,hate) choosen third ... Thanks,
mils
|
Administrator
|
Please imagine I am willing to take 5 minutes of my time to parse your input and output and try to discern a relationship and evolve a solution. FAIL!
You need to explain how 1 turns into 2 without leaving a lot to ESP and/or imagination. You are probably being paid to do this. No one here is. Make it easy for people to help you by making your question CLEAR!
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?" |
Administrator
|
In reply to this post by mils
See VARSTOCASES and rethink that second data structure. Wide format is inappropriate here.
OTOH, we don't know what you are doing ;-) Your definition of a 'case' in the second format is ambiguous at best wrt to the first. Seat of the pants marketing research??? --
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?" |
Ok, Ok David... you win :-)
Let's imagine an even less complicated scenario. In the following example, I have two respondents. Each one sees the same set of ads (a1 a2 a3) and have to choose one that he/she likes and one that he/she dislikes. These are the answers. Respondent one likes: a1 and dislikes: a2 Respondent two likes: a2 and dislikes: a3 DATA LIST /id 1 version 3 att1_1 5-6 (A) att2_1 8-9 (A) att3_1 11-12 (A) q3aa_1 14-15 (A) q3ab_1 17-18 (A). BEGIN DATA 1 1 a1 a2 a3 a1 a2 2 1 a1 a2 a3 a2 a3 END DATA. Now, I want to transpose the answers, since they both saw the same set of ads (a1 a2 a3) i would like to see their answers next to each other... att_1 att_2 att_3 answer11 answer12 answer21 answer22 a1 a2 a3 a1 a2 a2 a3 I hope this is now, more clear? Sorry to waste anyone's time ;-) Thanks for your help in advance!
mils
|
In reply to this post by mils
There's a couple of different ways that I can think of. One way is to tear the file apart and save set 1 of each version to one file and set 2 of each version to another file and to then add the two files together. So the idea would be this. (Warning: not tested!)
Compute set=1. Save outfile=set1/keep=version set att1_1 att2_1 att3_1 q3aa_1 q3ab_1. Compute set=2. Save outfile=set2/keep=version set att1_2 att2_2 att3_2 q3aa_2 q3ab_2 Add files file=set1/rename=( att1_1 att2_1 att3_1 q3aa_1 q3ab_1=att1 att2 att3 q3aa q3ab)/ file=set2/rename=( att1_2 att2_2 att3_2 q3aa_2 q3ab_2=att1 att2 att3 q3aa q3ab)/by version set. Casestovars id=version set. This line right here: The real dataset has only 4 versions with 20 set of ads each, could cause problems. I don't understand it because 4 versions, each with 2 sets of ads, is a total of 8 sets of ads. Something else must be going on or I don't understand what is being said. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of mils Sent: Thursday, June 11, 2015 9:10 AM To: [hidden email] Subject: Aggregate data Hi, I have the following data. In this example respondents will see two set of ads (each set containing 3 ads). The have to choose 2. There are 4 versions. Each version with a different set of ads. This are the responses: DATA LIST /id 1 version 3 att1_1 5-6 (A) att2_1 8-9 (A) att3_1 11-12 (A) q3aa_1 14-15 (A) q3ab_1 17-18 (A) att1_2 20-21 (A) att2_2 23-24 (A) att3_2 26-27 (A) q3aa_2 29-30 (A) q3ab_2 32-33 (A). BEGIN DATA 1 1 a1 a2 a3 a1 a2 z3 z8 a2 z8 z3 2 1 a1 a2 a3 a2 a3 z3 z8 a2 a2 z8 3 2 b3 b2 b8 b8 b2 t3 t7 c2 t3 c2 4 3 b3 a2 b2 b3 b2 r2 b3 a2 a2 b3 5 4 c3 c9 c1 c1 c9 c9 a1 a8 c9 a1 6 1 a1 a2 a3 a2 a3 a1 a2 a3 a3 a1 7 4 c3 c9 c1 c3 c1 c9 a1 a8 a8 a1 END DATA. I need to transpose the data, but I'm really struggling. I have tried different ways with the aggregate command but I can't get what I want. I would like to list the set of ads and then next to it the answers of each respondent. I would like to end up with something like this: DATA LIST /newid 1 att_1 3-4 (A) att_2 6-7 (A) att_3 9-10 (A) answer11 12-13 (A) answer12 15-16 (A) answer21 18-19 (A) answer22 21-22(A) answer31 24-25 (A) answer32 27-28(A) . BEGIN DATA 1 a1 a2 a3 a1 a2 a2 a3 a2 a3 2 z3 z8 a2 z8 z3 a2 z8 a3 a1 3 b3 b2 b8 b8 b2 4 t3 t7 c2 t3 c2 5 b3 a2 b2 b3 b2 6 r2 b3 a2 a2 b3 7 c3 c9 c1 c1 c9 c3 c1 8 c9 a1 a8 c9 a1 a8 a1 END DATA. I hope it makes sense. Please, let me know if you need further information. The real dataset has only 4 versions with 20 set of ads each. Any help will be really appreciate it. Thanks. ----- mils -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Aggregate-data-tp5729800.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 mils
See CASESTOVARS command.
My work is done here. --
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?" |
Thanks both,
This is the syntax that works for me... I still need to polish it, but is good enough :-) VARSTOCASES /ID=id1 /MAKE att_1 FROM att1_1 att1_2 /MAKE att_2 FROM att2_1 att2_2 /MAKE att_3 FROM att3_1 att3_2 /INDEX=att(2) /KEEP=id version q3aa_1 q3ab_1 q3aa_2 q3ab_2 /NULL=KEEP. VARSTOCASES /ID=id2 /MAKE answer1 FROM q3aa_1 q3aa_2 /MAKE answer2 FROM q3ab_1 q3ab_2 /INDEX=answer(2) /KEEP=id1 id version att att_1 att_2 att_3 /NULL=KEEP. compute check=$sysmis. if (att=1 and answer=1) check=1. if (att=1 and answer=2) check=0. if (att=2 and answer=1) check=0. if (att=2 and answer=2) check=1. fre check. select if check=1. SORT CASES BY att_1 att_2 att_3 . CASESTOVARS /ID=att_1 att_2 att_3 /GROUPBY=VARIABLE.
mils
|
Free forum by Nabble | Edit this page |