|
Hi,
I've got the following question, please help! This is a table of answers of a quiz in a course for each participant: Q1 Q2 Q3 Person1 4 3 1 Person2 2 3 3 Person3 1 3 3 ... For example the correct answer for Q1 is 2, for Q2 3 and for Q3 3. How can I make SPSS automatically enter for each participant whether the answer is correct or wrong? Thank you very very much in advance for your help. Regards, Serra ===================== 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 |
|
For this purpose, you need to use syntax.
There are a number of ways to do this, but I recommend the following: Create a simple one-record data file with the correct answers (the key) in it. You can use any text editor or the SPSS data editor. For your example, the first three variable values are 133. If the key is in a text file, read it into SPSS using the syntax for reading a text file. You can use the menus to generate the syntax. Label the variables with the same numbers as the answers; for example, if your questions are numbered Q1 to Q40, label the keyed answers Key1 to Key40. Using match files table option, match the key to every record. For this, you need to have a dummy constant in both files that is the same, such as Matchvar: COMPUTE MATCHVAR = 1. When both files have this value stored in every record, and assuming the key file is called key.DAT and the response file is the active file: MATCH FILES /FILE = * /TABLE = key.DAT /BY MATCHVAR. * Then score the test. COMPUTE TOTALSCORE = 0. DO REPEAT RESPONSE = Q1 TO Q40 /KEY = KEY1 TO KEY40. IF RESPONSE EQ KEY TOTALSCORE = TOTALSCORE + 1. END REPEAT. That should do it. David Wasserman Custom Data Analysis and SPSS Programming ----- Original Message ----- From: "Serra Koyuncu GMX" <[hidden email]> To: <[hidden email]> Sent: Sunday, December 30, 2007 12:30 PM Subject: help to a novice > Hi, > > I've got the following question, please help! > > This is a table of answers of a quiz in a course for each participant: > Q1 Q2 Q3 > Person1 4 3 1 > Person2 2 3 3 > Person3 1 3 3 > ... > > For example the correct answer for Q1 is 2, for Q2 3 and for Q3 3. How can > I > make SPSS automatically enter for each participant whether the answer is > correct or wrong? > > Thank you very very much in advance for your help. > > Regards, > Serra > > ===================== > 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 Serra Koyuncu GMX
Hi all-
I am having some problems with file matching in V16 that worked with my syntax from V15. But sometimes (other pairs of files) matching is working, so the command isn't completely lost. The variable in question is in both files & numeric in both. In fact I used the GUI to generate the syntax below [which means the variable was found in both files to ALLOW it to be moved into the key variables area in the lower right]. Anyone see the problem or know if this is patchable? **one last note, for "fun" I tried making the linkage in both directions (having file 1 open vs. having file 2 open) and in BOTH cases I get the same error message that the Input2 variable is the one missing. Thanks, Brian MATCH FILES /FILE=* /FILE='J:\Strategic Product Alignment\Active Products-2007\PC 84- Webinar '+ 'Analysis\FirstWebinarPurchase.sav' /RENAME (Cust = d0) /BY cust /DROP= d0. Variable(s) incorrectly used in 'BY' ------Input1------ ------Input2------ Result Type Variable name Type Variable name cust num cust (missing) Codes: num = numeric; sn = string of length n >Error # 5126 >The BY variable list is invalid. All the variables on the list must exist on >all the input files, and each variable must be of the same type (numeric, or >strings of the same length) on all the input files. >This command not executed. >Note # 5145 >The working file has been restored, and subsequent commands may access the >working file. EXECUTE. ===================== 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 |
|
Brian:
My help file for V15 says RENAME ranames variables on the input files before they are processed by MATCH FILES Your error msg matches this-- it says that "cust" doesn't exist in the second input file. That is the result of the RENAME command-- the variable cust no longer exists in the version of the file to be matched. I tried this syntax with V15 and reproduced the error. I'm surprised the syntax works sometimes-- when it works is the rename and drop used on the matching variable? --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Brian Moore Sent: Monday, December 31, 2007 4:07 PM To: [hidden email] Subject: V16 Problem With Merge Files Hi all- I am having some problems with file matching in V16 that worked with my syntax from V15. But sometimes (other pairs of files) matching is working, so the command isn't completely lost. The variable in question is in both files & numeric in both. In fact I used the GUI to generate the syntax below [which means the variable was found in both files to ALLOW it to be moved into the key variables area in the lower right]. Anyone see the problem or know if this is patchable? **one last note, for "fun" I tried making the linkage in both directions (having file 1 open vs. having file 2 open) and in BOTH cases I get the same error message that the Input2 variable is the one missing. Thanks, Brian MATCH FILES /FILE=* /FILE='J:\Strategic Product Alignment\Active Products-2007\PC 84- Webinar '+ 'Analysis\FirstWebinarPurchase.sav' /RENAME (Cust = d0) /BY cust /DROP= d0. Variable(s) incorrectly used in 'BY' ------Input1------ ------Input2------ Result Type Variable name Type Variable name cust num cust (missing) Codes: num = numeric; sn = string of length n >Error # 5126 >The BY variable list is invalid. All the variables on the list must exist on >all the input files, and each variable must be of the same type (numeric, or >strings of the same length) on all the input files. >This command not executed. >Note # 5145 >The working file has been restored, and subsequent commands may access the >working file. EXECUTE. ===================== 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 |
|
Hi all-
Turns out that for variables to be identical for matching purposes they must be of the same CASE, though the GUI does successfully recognize them as identical in the first part [won't both be allowed to be in the merged file]. This may not be new with v16, but I'd like to vote that this be declared a bug [at a minimum that all pieces of the same command have similar standards whatever they are declared to be]. Anyway - thanks Jim for your suggestion and all of you for this great forum. Regards, Brian -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marks, Jim Sent: Monday, December 31, 2007 3:30 PM To: [hidden email] Subject: Re: V16 Problem With Merge Files Brian: My help file for V15 says RENAME ranames variables on the input files before they are processed by MATCH FILES Your error msg matches this-- it says that "cust" doesn't exist in the second input file. That is the result of the RENAME command-- the variable cust no longer exists in the version of the file to be matched. I tried this syntax with V15 and reproduced the error. I'm surprised the syntax works sometimes-- when it works is the rename and drop used on the matching variable? --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Brian Moore Sent: Monday, December 31, 2007 4:07 PM To: [hidden email] Subject: V16 Problem With Merge Files Hi all- I am having some problems with file matching in V16 that worked with my syntax from V15. But sometimes (other pairs of files) matching is working, so the command isn't completely lost. The variable in question is in both files & numeric in both. In fact I used the GUI to generate the syntax below [which means the variable was found in both files to ALLOW it to be moved into the key variables area in the lower right]. Anyone see the problem or know if this is patchable? **one last note, for "fun" I tried making the linkage in both directions (having file 1 open vs. having file 2 open) and in BOTH cases I get the same error message that the Input2 variable is the one missing. Thanks, Brian MATCH FILES /FILE=* /FILE='J:\Strategic Product Alignment\Active Products-2007\PC 84- Webinar '+ 'Analysis\FirstWebinarPurchase.sav' /RENAME (Cust = d0) /BY cust /DROP= d0. Variable(s) incorrectly used in 'BY' ------Input1------ ------Input2------ Result Type Variable name Type Variable name cust num cust (missing) Codes: num = numeric; sn = string of length n >Error # 5126 >The BY variable list is invalid. All the variables on the list must exist on >all the input files, and each variable must be of the same type (numeric, or >strings of the same length) on all the input files. >This command not executed. >Note # 5145 >The working file has been restored, and subsequent commands may access the >working file. EXECUTE. ===================== 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 ===================== 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 |
|
There may be a bug in the dialog UI for Match Files (Merge Files>Add Variables), but the Match File command itself is not case-sensitive in regard to matching variable names. The following example works correctly in SPSS 16:
data list free /idvar var1. begin data 1 1 2 2 3 3 end data. sort cases by idvar. dataset name one. data list free /IDVAR var2. begin data 1 4 2 5 3 6 end data. sort cases by IDVAR. dataset name two. match files file=one /file=* /by IdVaR. execute. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Brian Moore Sent: Wednesday, January 02, 2008 2:38 PM To: [hidden email] Subject: Re: V16 Problem With Merge Files -solved Hi all- Turns out that for variables to be identical for matching purposes they must be of the same CASE, though the GUI does successfully recognize them as identical in the first part [won't both be allowed to be in the merged file]. This may not be new with v16, but I'd like to vote that this be declared a bug [at a minimum that all pieces of the same command have similar standards whatever they are declared to be]. Anyway - thanks Jim for your suggestion and all of you for this great forum. Regards, Brian -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marks, Jim Sent: Monday, December 31, 2007 3:30 PM To: [hidden email] Subject: Re: V16 Problem With Merge Files Brian: My help file for V15 says RENAME ranames variables on the input files before they are processed by MATCH FILES Your error msg matches this-- it says that "cust" doesn't exist in the second input file. That is the result of the RENAME command-- the variable cust no longer exists in the version of the file to be matched. I tried this syntax with V15 and reproduced the error. I'm surprised the syntax works sometimes-- when it works is the rename and drop used on the matching variable? --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Brian Moore Sent: Monday, December 31, 2007 4:07 PM To: [hidden email] Subject: V16 Problem With Merge Files Hi all- I am having some problems with file matching in V16 that worked with my syntax from V15. But sometimes (other pairs of files) matching is working, so the command isn't completely lost. The variable in question is in both files & numeric in both. In fact I used the GUI to generate the syntax below [which means the variable was found in both files to ALLOW it to be moved into the key variables area in the lower right]. Anyone see the problem or know if this is patchable? **one last note, for "fun" I tried making the linkage in both directions (having file 1 open vs. having file 2 open) and in BOTH cases I get the same error message that the Input2 variable is the one missing. Thanks, Brian MATCH FILES /FILE=* /FILE='J:\Strategic Product Alignment\Active Products-2007\PC 84- Webinar '+ 'Analysis\FirstWebinarPurchase.sav' /RENAME (Cust = d0) /BY cust /DROP= d0. Variable(s) incorrectly used in 'BY' ------Input1------ ------Input2------ Result Type Variable name Type Variable name cust num cust (missing) Codes: num = numeric; sn = string of length n >Error # 5126 >The BY variable list is invalid. All the variables on the list must exist on >all the input files, and each variable must be of the same type (numeric, or >strings of the same length) on all the input files. >This command not executed. >Note # 5145 >The working file has been restored, and subsequent commands may access the >working file. EXECUTE. ===================== 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 ===================== 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 Serra Koyuncu GMX
At 02:30 PM 12/30/2007, Serra Koyuncu GMX wrote:
>This is a table of answers of a quiz in a course for each participant: > Q1 Q2 Q3 >Person1 4 3 1 >Person2 2 3 3 >Person3 1 3 3 >... > >For example the correct answer for Q1 is 2, for Q2 3 and for Q3 3. >How can I make SPSS automatically enter for each participant whether >the answer is correct or wrong? David Wasserman is right, that this is easiest to do in syntax. I agree with using DO REPEAT, as he suggested. Here's a variation. It's "data in code"; that is, the correct answers are in the syntax file, rather than read from a data file. There are drawbacks to that, but I think not serious in your case; and this may be easier to write. Code not tested: If you only want the total number of answers that are right: COMPUTE SCORE = 0. DO REPEAT RESPONSE = Q1 Q2 Q3 /CORRECT = 2 3 3. . IF RESPONSE EQ CORRECT SCORE = SCORE + 1. END REPEAT. If you want to mark individual scores 'right' or 'wrong', DO REPEAT RESPONSE = Q1 Q2 Q3 /CORRECT = 2 3 3 /MARK = MK1 MK2 MK3. . COMPUTE MARK = 0. . IF RESPONSE EQ CORRECT MARK = 1. END REPEAT. Now "MK1" is 1 if question 1 is answered correctly, etc. ===================== 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 |
