Hello,

For my research, I have a demographic survey with different households and different observations per households (the individuals). Each individual is defined by the relationship he has towards the head of the household.

Here is my data:
individualID householdID gender relation_to_head
1 1 0 1
2 1 1 2
3 1 1 3
4 1 0 3
5 2 0 1
6 2 1 2
7 2 1 6
8 2 0 3
9 2 0 3
10 3 0 1
11 3 1 2
12 4 0 1
13 4 1 2
14 4 1 3
15 5 0 1
16 5 1 2
17 5 0 3
18 5 1 4
19 5 0 5
20 5 0 5
The key for understanding the relationship_to_head variable is the following:
1=Head
2=Spouse
3=Child
4=Mother/father
5=Grandchild
6=Child-in-law
For gender, 0=male and 1=female

The new variable that I want to create is whether the mother-in-law is present in the household. If we follow the logic, it should give only the householdID=2 and householdID=5.

Can you guys help me writing the code line for this new variable? I assume it has something to do with by household: but I can't add relationship_to_head==1 & relationship_to_head==2, etc.

Thank you very much in advance.