3
votes

I have 7 variables:(A,B,C,D,E,F,G). How in menu Transform-compute variable in SPSS to summarize the variables whose value is equal to 1? I mean for example:

A=1
B=2
C=1
D=3
E=5
F=1
G=2

Here, only 3 vars have value 1. How to set a condition: sum if the value of the variable is equal to 1

1

1 Answers

1
votes

You can get the value you asked for by using COUNT (in the TRANSFORM menu) instead of COMPUTE. Counting how many of your variables have 1 in them will give the same result as summing them up.

If you want to define a more complicated condition, e.g. all values that are 1 or 2, you'll need to go to syntax and loop through your variables. Here's an example to get you started:

compute YourSum=0.
do repeat VR=A B C D E F G.
if VR=1 or VR=2 YourSum=YourSum+VR.
end repeat.

This loop goes through the variable list, and for each variable - if the value is 1 or 2, it is added to the sum.