Coding knowledge score

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Rena Jenkins
Posts: 4
Joined: Thu Aug 21, 2014 12:52 pm

Coding knowledge score

Postby Rena Jenkins » Thu Aug 21, 2014 12:59 pm

Hi

I am new to SPSS and have previously worked in Stata. I would like to create a knowledge score which is increased by 1 for each question correctly answered. The correct answer may be 1 or 2 depending on the question.

In Stata I would do something like:
gen score=0
replace score=score+1 if ans1==1
replace score=score+1 if ans2==2
replace score=score+1 if ans3==2 ... and so on.

How would you do this with SPSS syntax?

Thanks

Rena
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Coding knowledge score

Postby GerineL » Thu Aug 21, 2014 1:55 pm

Can't you just make a sum of all the items?
I.e., why is the process of (+1) necessary?
Rena Jenkins
Posts: 4
Joined: Thu Aug 21, 2014 12:52 pm

Re: Coding knowledge score

Postby Rena Jenkins » Thu Aug 21, 2014 2:55 pm

You would need some sort of conditional statement, but I don't know how to do that in SPSS. I have looked at COMPUTE examples but I can't see what I want. For example, if the Iif statement existed in SPSS syntax, it might be something like:
COMPUTE score=Iif(ans1=1,1,0)+Iif(ans2=2,1,0)+Iif(ans3=2,1,0)+...

Can anybody help?
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Coding knowledge score

Postby GerineL » Fri Aug 22, 2014 9:51 am

conditional statements you can create using if-function.

For instance

(if var1 = 1 & var2 = 1) var3 = 1.
(if var1 = 0 & var2 = 0) var3 = 0.
(if var1 = 1 & var2 = 0) var3 = 2.
execute.



You can create a sum score using the sum function.

compute var3 = sum(var1,var2,var4).
execute.



If you don't have a variable yet that indicates whether an answer was right or not, first use if, then use compute.


if (var1 = 6) var1right = 1.
if (var2 = 5) var2right = 1.
if (var3 = 2) var3right = 1.
execute.


compute totalright = sum (var1right, var2right, var3right).
execute.



is that what you need? if not, please indicate what the conditions are, or what the problem exactly is.

Who is online

Users browsing this forum: No registered users and 1 guest

cron