Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a new variable with multiple if qualifiers

    I am attempting to create a new variable which is only comprised of respondents who answered all specific questions correctly

    There are six questions represented by the variables: knowledge_1, knowledge_2, knowledge_3, knowledge_4, knowledge_5 and knowledge_6

    The correct answer for _1, _2, _4 and _5 is the value 1
    The correct answer for _3 and _6 is the values 2

    How would I create a variable/a group which only includes respondents who have answered all the questions correctly?

  • #2
    Code:
    gen byte its_all_right = (knowledge_1 == 1)*(knowledge_2 == 1)*(knowledge_4 == 1)*(knowledge_5 == 1)*(knowledge_3 == 2)*(knowledge_6 == 2)
    Last edited by Hemanshu Kumar; 16 Jan 2023, 10:33.

    Comment


    • #3
      Great, thank you!

      Comment

      Working...
      X