I have a time-series dataset with the following form:
ID Year
1 2000
2 2000
3 2000
1 2001
2 2001
3 2001
4 2001
...
I need to create dyads so that the dates looks as follows:
IDa IDb Year
1 2 2000
1 3 2000
...
1 4 2001
...
The original dataset contains more than 17,000 unit-years. I have tried using Ferguson's DYADS, but I have run into a couple problems:
ID Year
1 2000
2 2000
3 2000
1 2001
2 2001
3 2001
4 2001
...
I need to create dyads so that the dates looks as follows:
IDa IDb Year
1 2 2000
1 3 2000
...
1 4 2001
...
The original dataset contains more than 17,000 unit-years. I have tried using Ferguson's DYADS, but I have run into a couple problems:
- The dyads command cannot be used with either by or if, so I cannot create dyads within years. (This means dyads creates dyads containing, for example, (1,2000) and (1,2001), which I do not want;
- This results in the computer attempting to create more than 224 million observations (dyads begins by creating N*N observations, then reducing that to N(N-1)/2 dyads), which should be far fewer when taking years into account;
- I have tried using a loop with foreach, but I am unsure about my coding as Stata begins with creating all 224+ million observations.
Comment