SPSS check if same answers in set of variables

48 Views Asked by At

I have 8 variables and I need to check whether the same answer has been given at least 3 times in these 8 variables per case. These are numerical variables, so there is a wide range of answers. So counting specific values with the COUNT function does not really work here given the amount of possible answers. Anybody that has an idea on how this would be possible? Thank you.

1

There are 1 best solutions below

2
On

This will create a new variable for every possible answer, with the number of times it was mentioned. This assumes there are 15 possible answers - you can correct it to the real number:

do repeat vr=ans01 to ans15/vl=1 to 15.
count vr=var1 to var8 (vl).
end repeat.
exe.

At this point if you want you can use the following to change the new variables to contain the value 1 if the answer was mentioned 3 or more times, or 0 if not:

recode ans01 to ans15 (0 1 2=0)(3 thru hi=1).

EDIT: A different solution is needed if possible answers are not known in advance and/or contain non integer values. The syntax below assumes there is some row ID variable in the data:

varstocases /make ans from var1 to var8.
aggregate outfile=* /break=ID ans /ntimes=n.

you now have a list of the number of times each answer was given for each ID. You can now filter only the answers given 3 times or more:

select if ntimes>=3.
execute.