Hello, I am using household data and need to create a dummy variable between pairs of variables to indicate if they are same-sex or not. My variables include Gender (2=male, 4=female), HouseholdID (string of numbers), and StatusinHH (I am concerned with only values 1=Head of Household and 2=Spouse, although there are other options (3=child, etc)).

input str11 householdid float(gender hhstatus)
"000015002" 2 1
"000015002" 4 2
"000015003" 2 1
"000015003" 4 2
"000015004" 2 1
"000015004" 4 2
"000015004" 2 5
"000015004" 4 4
"000015005" 2 1
"000015005" 4 2
"000015006" 4 1
"000015007" 4 1
"000015007" 4 5
"000015007" 4 5
"000015008" 4 1
"000015008" 4 4
"000015009" 2 1
"000015009" 4 2
"000015010" 2 1
"000015010" 4 2
"000015010" 4 3
"000015011" 2 1
"000015011" 4 2
"000015012" 2 1
"000015012" 4 2
"000015012" 4 3

I need to create a dummy variable for each person within the household to indicate whether they are in a same sex relationship or not. This will be based on having same gender between the 2 individuals with a StausinHH of 1 or 2 within the same household.

Can anybody help me with how to go about this? Thanks so much!