Hi all,
I want to generate a dummy variable where over the past three years the the lead bank was a participant in a loan led by one of the current participants.
Companyid Participantid
5978 5905
So company 5978 has a link with 5905, but I am wondering if in a period of three years 5905 also created a link with 5978.
I already created the three year period in the following way:
I followed with creating variables where the lead and participant are matched, and the other way around:
In short: I want to create a variable where i can find whether the leader has been a participant, and if in this case the lead bank has been a participant in one of his loans.
Example:
This is of course a very simplified example. If this is a success I still need to find if this holds for certain periods.
I tried using Vlookup, but that wasn't a success, at least with the knowledge I have.
Furthermore, if I could swap the numbers in the participantleaderid around it would make life a lot easier.
I hope you are able to help me out!
Kind regards,
David de Vos
I want to generate a dummy variable where over the past three years the the lead bank was a participant in a loan led by one of the current participants.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(facilityid companyid participantid) int datayear byte period 71268 5978 5905 2000 1 71268 5978 27454 2000 1 71268 5978 33509 2000 1 71268 5978 6001 2000 1 71268 5978 29986 2000 1 71590 6031 26335 2000 1 71590 6031 5972 2000 1 71590 6031 6532 2000 1 71590 6031 33878 2000 1 71590 6031 26175 2000 1 71590 6031 6443 2000 1 71590 6031 34769 2000 1 71590 6031 7838 2000 1 71590 6031 8861 2000 1 71590 6031 8834 2000 1 71590 6031 9849 2000 1 71590 6031 8926 2000 1 71590 6031 23679 2000 1 71590 6031 23087 2000 1 71590 6031 5851 2000 1 71590 6031 7861 2000 1 71590 6031 8857 2000 1 71590 6031 23222 2000 1 71590 6031 30898 2000 1 71590 6031 29380 2000 1 71590 6031 7829 2000 1 71590 6031 7855 2000 1 71590 6031 7922 2000 1 71590 6031 5893 2000 1 71592 6031 6443 2000 1 71592 6031 9849 2000 1 71592 6031 23222 2000 1 71592 6031 33878 2000 1 71592 6031 7855 2000 1 71592 6031 5851 2000 1 71592 6031 26175 2000 1 71592 6031 34769 2000 1 71592 6031 26335 2000 1 71592 6031 23679 2000 1 71592 6031 8857 2000 1 71592 6031 29380 2000 1 71592 6031 5893 2000 1 71592 6031 8926 2000 1 71592 6031 7829 2000 1 71592 6031 8861 2000 1 71592 6031 23087 2000 1 71592 6031 6532 2000 1 71592 6031 8834 2000 1 71592 6031 7861 2000 1 71592 6031 7838 2000 1 71592 6031 9197 2000 1 71592 6031 5972 2000 1 71592 6031 30898 2000 1 71592 6031 7922 2000 1 71592 6031 84644 2000 1 73007 7827 12316 2000 1 73007 7827 5851 2000 1 73007 7827 21976 2000 1 73007 7827 6827 2000 1 73567 7827 12316 2000 1 73567 7827 5851 2000 1 73567 7827 6827 2000 1 73567 7827 21976 2000 1 75031 24010 6443 2000 1 75031 24010 32641 2000 1 75031 24010 33982 2000 1 75032 24010 32641 2000 1 75032 24010 33982 2000 1 75032 24010 6179 2000 1 75032 24010 6443 2000 1 75596 6179 7873 2000 1 75596 6179 30898 2000 1 75596 6179 6123 2000 1 75596 6179 7827 2000 1 75596 6179 7878 2000 1 75596 6179 6532 2000 1 75596 6179 7855 2000 1 75596 6179 1468 2000 1 75596 6179 84644 2000 1 75596 6179 5893 2000 1 75596 6179 29112 2000 1 75596 6179 5905 2000 1 75596 6179 30309 2000 1 75596 6179 7860 2000 1 75596 6179 8873 2000 1 75596 6179 18874 2000 1 75596 6179 8857 2000 1 75596 6179 17337 2000 1 75596 6179 7861 2000 1 75596 6179 6089 2000 1 75596 6179 5848 2000 1 75596 6179 5889 2000 1 75596 6179 5851 2000 1 75596 6179 7845 2000 1 75596 6179 6895 2000 1 75596 6179 8834 2000 1 75596 6179 7894 2000 1 75596 6179 9141 2000 1 75596 6179 6050 2000 1 75598 5893 18642 2000 1 end
5978 5905
So company 5978 has a link with 5905, but I am wondering if in a period of three years 5905 also created a link with 5978.
I already created the three year period in the following way:
Code:
gen period=1 if inrange(datayear, 2000, 2002) replace period=2 if inrange(datayear, 2001, 2003) replace period=3 if inrange(datayear, 2002, 2004) replace period=4 if inrange(datayear, 2003, 2005) replace period=5 if inrange(datayear, 2004, 2006) replace period=6 if inrange(datayear, 2005, 2007) replace period=7 if inrange(datayear, 2006, 2008) replace period=8 if inrange(datayear, 2007, 2009) replace period=9 if inrange(datayear, 2008, 2010) replace period=10 if inrange(datayear, 2009, 2011) replace period=11 if inrange(datayear, 2010, 2012) replace period=12 if inrange(datayear, 2011, 2013) replace period=13 if inrange(datayear, 2012, 2014) replace period=14 if inrange(datayear, 2013, 2015)
Code:
egen leaderparticipantid = concat(companyid participantid), punct(,) egen participantleaderid = concat(participantid companyid), punct(,)
Example:
leadparticipantid | participantleaderid | dummyvariable | Explaination |
1,2 | 2,1 | 1 | |
1,3 | 3,2 | 0 | |
2,4 | 4,3 | 1 | Here is 1, because it matches 3,4 in the leadpart variable |
2,6 | 6,2 | 0 | |
3,4 | 4,3 | 1 |
This is of course a very simplified example. If this is a success I still need to find if this holds for certain periods.
I tried using Vlookup, but that wasn't a success, at least with the knowledge I have.
Furthermore, if I could swap the numbers in the participantleaderid around it would make life a lot easier.
I hope you are able to help me out!
Kind regards,
David de Vos
Comment