Hi,
I have the follwoing sample:
Code:
ssc install dataex
clear
input int year str6 staff_id str5 hotel_id byte(waitress receptionist)
2009 "124665" "23453" 1 0
2009 "455543" "23453" 0 1
2009 "334532" "23453" 1 0
2009 "888976" "23453" 1 0
2010 "124665" "23453" 1 0
2010 "455543" "23453" 0 1
2010 "334532" "23453" 1 0
2010 "556333" "23453" 1 0
2011 "124665" "23453" 1 0
2011 "877776" "23453" 0 1
2011 "666755" "23453" 1 0
2011 "556333" "23453" 1 0
2012 "124665" "23453" 1 0
2012 "877776" "23453" 0 1
2012 "666755" "23453" 1 0
2012 "777554" "23453" 1 0
2009 "564400" "66766" 1 0
2009 "990988" "66766" 0 1
2009 "008998" "66766" 1 0
2009 "669009" "66766" 1 0
2010 "564400" "66766" 1 0
2010 "990988" "66766" 0 1
2010 "455543" "66766" 1 0
2010 "556333" "66766" 1 0
2011 "564400" "66766" 1 0
2011 "777799" "66766" 0 1
2011 "881100" "66766" 1 0
2011 "556333" "66766" 1 0
2012 "669009" "66766" 1 0
2012 "990988" "66766" 0 1
2012 "881100" "66766" 1 0
2012 "778811" "66766" 1 0
2009 "564400" "99088" 1 0
2009 "004377" "99088" 0 1
2009 "110925" "99088" 1 0
2009 "778811" "99088" 1 0
2010 "564400" "99088" 1 0
2010 "004377" "99088" 0 1
2010 "669009" "99088" 1 0
2010 "888976" "99088" 1 0                              
end
Firstly, I would like to create a dummy variable (equals 1 and 0 otherwise) if a receptionist were changed with another new receptionist by comparing the current year with the previous year(s) for each firm-year observation. For example, by comparing the years 2009 and 2010 with 2011, the receptionist No. "877776" in Hotel No. "23453", should be identified as a newly employed receptionist in 2011(equal 1).

Secondly, I would like to create a dummy variable (equals 1 and 0 otherwise) if the waitress in a particular firm-year observation joined the hotel after the receptionist assumed office. In other words, I would like to identify those who came after the employment of the receptionist of the hotel. Note that I only have one receptionist per firm-year observation.

Thanks in advance