Dear All,

How can I check if the sex of the head and the spouse are different. For example if head is male then spouse should be female. How to also check if the member is spouse than the marital status of a spouse should not be "never married". So how I can identify cases like these.

A sample of my dataset. Thank you in advance

copy starting from the next line ------ ----------------
Code:
* Example generated by -dataex-. To install: ssc install    dataex
clear
input float new_slno byte(Q1_3 Q1_4) int Q1_5 byte Q1_6
1 1  1 40 3
1 2 14 79 3
1 1  2 35 1
1 1  3 17 1
1 1  3 14 .
1 1  3  9 .
1 2  4  2 .
2 1  1 46 3
2 1  2 43 1
2 2  4 21 3
2 2  4 18 1
3 2  1 30 3
3 1  2 23 3
3 2 16 15 1
3 2 16 10 .
3 2  4  5 .
4 2  1 38 3
4 1 19 77 4
4 1  2 45 3
4 1  3 21 3
4 2  4 18 1
4 2  4 12 .
5 1  1 46 3
5 2  2 37 3
6 2  1 35 3
6 1  2 34 3
6 2  4 13 .
6 2  4  8 .
7 1  1 34 3
7 2  2 33 3
end
label values Q1_3 Q1_3
label def Q1_3 1 "Male", modify
label def Q1_3 2 "Female", modify
label values Q1_4 Q1_4
label def Q1_4 1 "Head", modify
label def Q1_4 2 "Spouse", modify
label def Q1_4 3 "Son", modify
label def Q1_4 4 "Daughter", modify
label def Q1_4 14 "Mother-in-law", modify
label def Q1_4 16 "Sister-in-law", modify
label def Q1_4 19 "Uncle", modify
label values Q1_6 Q1_6
label def Q1_6 1 "Never married", modify
label def Q1_6 3 "Married", modify
label def Q1_6 4 "Divorced", modify
copy up to and including the previous line - ----------------