There is a data set of the following structure:
firm_ID partner_ID start_date end_date
1 2 01jan2001 15mar2001
1 3 15feb2001 30apr2001
2 4 20mar2001 14may2001
The data set shows the duration of partnership of firm_ID with partner_ID. Here, firm_ID and partner_ID (both integers) refer to a unique identifier of the firms .
Using Stata, I want to create a summary table, which shows for each unique firm_ID the number of its partnerships, by month and year. If the partnership existed for at least one day in a given month, it should be counted. If firm 1 reports a partnership with firm 2 but firm 2 doesn't report a partnership with firm 1, then it should only be counted for firm 1 and not firm 2.
For the example above, the summary table is:
firm_ID 01/2001 02/2001 03/2001 04/2001 05/2001
1 1 2 2 1 0
2 0 0 1 1 1
The variable firm_ID has 8,000 unique observations and the time span is 01/2001 - 12/2013. Thus, the resulting summary table should have the number of rows equal to 8,000 and the number of columns equal to 12*13=156 (number of months during 01/2001 - 12/2013).
Conceptually, what is the algorithm of solving this task using Stata? Thank you.