Dear all,

I'm trying to find the correct command for the following:
I have a dataset where each company founded in a certain year, has different employees who are either on the board or are managers and have a certain appointment year.

I would like to create a variable that shows the number of managers in a certain company (so not board members) if they were appointed in the same year as the company started.
This would be used to know if they are part of the founding team. The variable would contain the same value across all rows for the same companyID/founding year combo (there might be companies, with same ID but different founding years).

Unfortunately, I can't share the dataset due to privacy issues.
Example of how the dataset looks, with in bold what I would like to have as a result/ the new variable I would like to create

company ID founding year employee id appointment year manager role foundingmanager
123 2010 abc 2010 manager 1
123 2010 def 2012 manager 1
123 2010 ghi 2010 board 1
456 2015 jkl 2015 board 0
789 2006 mno 2006 board 2
789 2006 pqr 2006 manager 2
789 2006 stu 2006 manager 2
Thanks to this forum, I know to create a distinct count for the employees per company ID would be as follows:
Code:
 
 egen distinctemployee = tag(companyID employeeID)
But I'm not sure how to write down the conditions :
if founding year for the observation equals the appointment year for the observation
if manager role value equals manager

I'm sorry, as this might be a simple answer, but I did not immediately find what I was looking for on the forum.
Thank you in advance for all your help.

Best regards,
Laura