Help creating a function or loop to check for correct answers

Hello all,

I've never used loops or functions before so I could use some help. I'm trying to find a way to check the survey responses of students in my study, since ~27% (158 people) of the sample didn't complete it. Specifically, I'm trying to come up with a way to find out how many of these 158 failed out due to my attention checks vs. dropped out and just didn't want to take the time to do it.

There are three attention checks per condition, and 6 conditions. If someone got any one of the questions wrong they were booted out of the survey, and thus should get a 1 in a variable I want to create called "AttnCheck_Failed". My codebook is posted.

I've never done something like this before but I imagine it might look something like this, in English:

In (X) condition, check questions (Q134 & Q135 & Q136). If (Q134 does NOT equal 1 | Q135 does NOT equal 3 | Q136 does NOT equal 1.5), then set AttnCheck_Failed equal to 1; else=0.

This loop would repeat for each of the conditions in the accompanying picture. Can anyone help translate this into usable code?

If you could share sample data on a copy/paste friendly format (or ideally a complete REPRoducible EXample (reprex)) maybe we could give you a better solution than a loop.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.