I would like to create a dummy variable (equals 1 and 0 otherwise) if the waitress in a particular hotel is serving as a receptionist for another hotel/hotels in the same year. I am only interested in waitresses who are serving as a receptionist in other hotels (if any) and not vice versa. Note that waitresses can not take more than one receptionist position but waitresses 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. To identify observations with the same staff_ID and year, I have generated a new ID (ID_generated) (this is generated via excel using the CONCATENATE command. If you know how to do it in STATA, please let me know). I have a large number of observations and I am wondering if there are any commands to create such dummy variables.
In the following example, you can notice that in 2009, the staff No. 124665 served as a waitress in a hotel and a receptionist in another hotel in the same year (I would like to identify this as 1):
Year | Staff ID | Hotel_ID | ID_generated | Waitress | Receptionist
2009 | 124665 | 23453 | 2009124665 ______1________ 0
2010 | 436455 | 34534 | 2010436455______ 0 ________1
2002 | 543645 | 37684 | 2002543645______ 0 ________1
2009 | 124665 | 32478 | 2009124665______ 0________1
2009 | 979987 | 34545 | 2009979987______ 0 ________1
2013 | 097077 | 34556 | 2013097077______ 1_________0
In the following example, you can notice that in 2009, the staff No. 124665 served as a waitress in a hotel and a receptionist in another hotel in the same year (I would like to identify this as 1):
Year | Staff ID | Hotel_ID | ID_generated | Waitress | Receptionist
2009 | 124665 | 23453 | 2009124665 ______1________ 0
2010 | 436455 | 34534 | 2010436455______ 0 ________1
2002 | 543645 | 37684 | 2002543645______ 0 ________1
2009 | 124665 | 32478 | 2009124665______ 0________1
2009 | 979987 | 34545 | 2009979987______ 0 ________1
2013 | 097077 | 34556 | 2013097077______ 1_________0
Comment