Dear All

I have a dataset where I want to check the relationship code and age of the household head to the members of the household.
For example each household has members and the relationship to the head was asked. I want to know whether there is an easier way to check the relationship code to the head based on the age. For example if the relation is mother/father/grand parent the age cannot be smaller than the head and if the relation is son or daughter the age cannot be more than the age of the head.

I have an example of the data set.,
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str32 HHNO byte(pno Q1_3 Q1_4 Q1_5)
"1" 0 1  1 59
"1" 1 2  2 52
"1" 2 2  4 70
"1" 3 1 17 34
"2" 0 2  1 31
"2" 1 2  4 55
"3" 0 1  1 48
"3" 1 2  2 41
"3" 2 2  4 88
"3" 3 2 11 17
"3" 4 1 13 72
"4" 0 1  1 44
"4" 1 2  2 40
"4" 2 1  3 11
"4" 3 2  4  8
"5" 0 1  1 34
"5" 1 2  2 36
"5" 2 1  9  9
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 9 "Grand-father", modify
label def Q1_4 11 "Grand-son", modify
label def Q1_4 13 "Father-in-law", modify
label def Q1_4 17 "Son-in-law", modify
------------------ copy up to and including the previous line ------------------

Thank you in advance