I HAVE the following data:
DirectorID | CompanyID | AwardYear | DegreeType |
1928993 | 62323 | 1998 | Undegrad |
1798822 | 62360 | 1998 | Undegrad |
2384193 | 467713 | 2003 | Other |
1769649 | 467713 | 2003 | Other |
1777732 | 1519459 | 2002 | Undegrad |
1627886 | 1519459 | 2003 | Undegrad |
1323941 | 1519459 | 2004 | Undergrad |
1839100 | 60212 | 2008 | Grad |
1706497 | 60212 | 2008 | Undergrad |
I want to count the number of unique rows (Matches) where a DirectorID matches with another DirectorID on ALL of the following criteria: (1) CompanyId, (2) within +/- one year of AwardYear, and (3) DegreeType.
The following output is what I WANT:
DirectorID | CompanyID | AwardYear | DegreeType | Matches |
1928993 | 62323 | 1998 | Undegrad | 0 |
1798822 | 62360 | 1998 | Undegrad | 0 |
2384193 | 467713 | 2003 | Other | 1 |
1769649 | 467713 | 2003 | Other | 1 |
1777732 | 1519459 | 2002 | Undegrad | 1 |
1627886 | 1519459 | 2003 | Undegrad | 2 |
1323941 | 1519459 | 2004 | Undergrad | 1 |
1839100 | 60212 | 2008 | Grad | 0 |
1706497 | 60212 | 2008 | Undergrad | 0 |
What code could be used to create the "Matches" variable?
Thank you!!