Deal all,

I have the following sample:
Code:
Year | Staff ID | Hotel_ID | Industry code | Waitress | Receptionist
2009 | 124665   | 23453    | 20            | 1            | 0
2010 | 436455   | 34534    | 30            | 0            | 1
2002 | 543645   | 37684    | 10            | 0            | 1
2009 | 124665   | 32478    | 20            | 0            | 1
2009 | 979987   | 34545    | 50            | 0            | 1
2013 | 097077   | 34556    | 30            | 1            | 0
2013 | 097077   | 34432    | 50            | 0            | 1
I used the following command to create a dummy variable (equals 1 and 0 otherwise) if a waitress in a particular hotel is serving as a receptionist for another hotel/hotels in the same year.

Code:
bysort staff_ID year: egen aux1 = max(Waitress)
bysort staff_ID year: egen aux2 = max(Receptionist)
gen wanted = aux1 & aux2
I am now interested in identifying which of those waitresses, who are serving as a receptionist in other hotels in the same year, are working for firms in the same industry. In other words, a waitress that works for a hotel that has the same two-digit industry code as the other hotel that the waitress works for as a receptionist should be identified as 1 and 0 otherwise.


Important notes:
I am only interested in waitresses who are serving as a receptionist in other hotels (if any) and not vice versa. Also, note that waitresses can not take more than one receptionist position but can take multiple waitresses positions in other hotels in the same year.
All staff are allocated with a unique ID regardless of being a waitress or receptionist.