
/***********************************************************************************************************/
/***********************************************************************************************************/
*This do-file produces Figure 4 ("Investmentgrade versus leveraged loan market")
* 
*Input
*- Master_Dealscan.dta
/***********************************************************************************************************/
/***********************************************************************************************************/


/****************************************************************/
/**********   0. Intros   ***************************************/
/****************************************************************/
set more off
global path "C:\Users\tobia\Dropbox\6_WIP Papers\Trends in Corporate Borrowing"

/****************************************************************/
/**********   1. Graph for the U.S.  *****************************/
/****************************************************************/

	*Loans
	use 	"$path/2_IntermediateFiles/Master_Dealscan.dta", clear
			
		keep 	if Country == "USA"
		keep if BaseRate == "LIBOR"
		keep if inlist(Currency, "United States Dollars")
			
		drop if LoanType2 == "Other"
		
		table leveraged igrade, c(sum FacilityAmt)
		table leveraged igrade, c(count FacilityAmt)
		
		keep if leveraged != . & igrade != . /*Market segment information missing*/
		drop if leveraged == 0 & igrade == 0 /*Loan classified as both not igrade and not leveraged*/
		drop if leveraged == 1 & igrade == 1 /*Loan classified as both igrade and leveraged*/
		
		gen cat = "Revolver" if LoanType4 == "Revolver" 
		replace cat = "TermLoanA" if LoanType4 == "TermLoanA"
		replace cat = "TermLoanB" if LoanType4 == "TermLoanB"
		
		collapse (sum) FacilityAmt, by(year cat leveraged)
		replace FacilityAmt = FacilityAmt / 1000	/*FacilityAmt from USD mn --> USD bn*/
		
		table year cat if leveraged == 0, c(mean FacilityAmt) format(%9.1f)
		
		#d ;
		twoway (line FacilityAmt year if leveraged == 0 & cat ==  "Revolver", color (black))
				(line FacilityAmt year if leveraged == 0 & cat ==  "TermLoanA", color (gs12))
				, legend(col(1) order(1 "Revolver" 2 "Term Loan") rowgap(*4)  size(small))
				title("Loans: Investment Grade", size(small))
				xtitle("Year") ytitle("Facility Amount in USD bn", size(small)) ylabel(0(200)1400, labsize(small) angle(90) nogrid) yscale(titlegap(*10))
				xlabel(2002(2)2019, labsize(small) angle(vertical)) xmtick(2002(1)2019, nolabels ticks)
				graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
				name(A, replace);
		#d cr
		graph		export "$path/3_Results/Figure4a.pdf", replace
		
		*Same as table (to be able to read off exact numbers)
		table year cat if leveraged == 1, c(mean FacilityAmt) format(%9.1f)
								
		#d ;
		twoway (line FacilityAmt year if leveraged == 1 & cat ==  "Revolver", color (black))
				(line FacilityAmt year if leveraged == 1 & cat ==  "TermLoanA", color (gs12))	
				(line FacilityAmt year if leveraged == 1 & cat ==  "TermLoanB", color (black) lpattern(dot) )
				, legend(col(1) order(1 "Revolver" 2 "Term Loan - Bank" 3 "Term Loan - Inst." )  size(small))
				title("Loans: Leveraged", size(small))
				xtitle("Year") ytitle("Facility Amount in USD bn", size(small)) ylabel(0(200)1400, labsize(small) angle(90) nogrid) yscale(titlegap(*10))
				xlabel(2002(2)2019, labsize(small) angle(vertical)) xmtick(2002(1)2019, nolabels ticks)
				graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
				name(B, replace);
		
		#d cr
		graph		export "$path/3_Results/Figure4b.pdf", replace
		
		*Same as table (to be able to read off exact numbers)
		table year cat if leveraged == 1, c(mean FacilityAmt) format(%9.1f)
		
		
	*Bonds
	import excel using "$path/0_Data/SIFMA/Corporate-US-Corporate-Issuance-SIFMA (2).xls", sheet("Issuance") cellrange(A7:C31) firstrow clear
	
		rename A year
		rename Grade InvestmentGrade
		rename Yield Leveraged
		
		keep if year >= 2002 & year <= 2019
		#d ;
			twoway (line InvestmentGrade year, color (black))
					(line Leveraged year, color (gs12))	
					, legend(col(1) order(1 "Investment Grade" 2 "Leveraged") rowgap(*4)  size(small))
					title("Bonds", size(small))
					xtitle("Year") ytitle("Issuance in USD bn", size(small)) ylabel(0(200)1400, labsize(small) angle(90) nogrid) yscale(titlegap(*10))
					xlabel(2002(2)2019, labsize(small) angle(vertical)) xmtick(2002(1)2019, nolabels ticks)
					graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
					name(C, replace);
			
			#d cr
		graph		export "$path/3_Results/Figure4c.pdf", replace
		
		graph combine A B C, col(3) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
		
		
		
		
		graph		export "$path/3_Results/Figure4.pdf", replace
		graph		export "$path/3_Results/Figure4.png", replace
	
		

/****************************************************************/
/**********   2. Graph for Europe  *****************************/
/****************************************************************/

	use 	"$path/2_IntermediateFiles/Master_Dealscan.dta", clear
			
		*Sample (similar as for US, but with additional restrictions on base rate and currency)
		keep if inlist(Country, "Austria", "Belgium", "Germany", "Finland", "France", "Greece", "Ireland", "Italy", "Luxembourg") | inlist(Country, "Netherlands", "Portugal", "Spain")	
		*keep if inlist(BaseRate, "LIBOR", "Euribor")
		keep if inlist(Currency, "Euro", "United Kingdom Pounds", "United States Dollars")
				
		drop if LoanType2 == "Other"
		
		table leveraged igrade, c(sum FacilityAmt)
		table leveraged igrade, c(count FacilityAmt)
		
		keep if leveraged != . & igrade != . /*Market segment information missing*/
		drop if leveraged == 0 & igrade == 0 /*Loan classified as both not igrade and not leveraged*/
		drop if leveraged == 1 & igrade == 1 /*Loan classified as both igrade and leveraged*/
		
		gen cat = "Revolver" if LoanType4 == "Revolver" 
		replace cat = "TermLoanA" if LoanType4 == "TermLoanA"
		replace cat = "TermLoanB" if LoanType4 == "TermLoanB"
		
		collapse (sum) FacilityAmt, by(year cat leveraged)
		replace FacilityAmt = FacilityAmt / 1000	/*FacilityAmt from USD mn --> USD bn*/
		
		table year cat if leveraged == 0, c(mean FacilityAmt) format(%9.1f)
		
		#d ;
		twoway (line FacilityAmt year if leveraged == 0 & cat ==  "Revolver", color (black))
				(line FacilityAmt year if leveraged == 0 & cat ==  "TermLoanA", color (gs12))
				, legend(col(1) order(1 "Revolver" 2 "Term Loan"))
				title("Investment Grade Market")
				xtitle("Year") ytitle("Facility Amount in USD bn") ylabel(0(100)500, labsize(small) angle(90) nogrid)
				xlabel(2002(1)2019, labsize(small) angle(vertical)) xmtick(2002(1)2019, nolabels ticks)
				graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
				name(A, replace);
		#d cr		
		
		*Same as table (to be able to read off exact numbers)
		table year cat if leveraged == 1, c(mean FacilityAmt) format(%9.1f)
								
		#d ;
		twoway (line FacilityAmt year if leveraged == 1 & cat ==  "Revolver", color (black))
				(line FacilityAmt year if leveraged == 1 & cat ==  "TermLoanA", color (gs12))	
				(line FacilityAmt year if leveraged == 1 & cat ==  "TermLoanB",  color (black) lpattern(dot) )
				, legend(col(1) order(1 "Revolver" 2 "Term Loan - Bank" 3 "Term Loan - Inst." ))
				title("Leveraged Market")
				xtitle("Year") ytitle("Facility Amount in USD bn") ylabel(0(100)500, labsize(small) angle(90) nogrid)
				xlabel(2002(1)2019, labsize(small) angle(vertical)) xmtick(2002(1)2019, nolabels ticks)
				graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
				name(B, replace);
		
		#d cr
		
		*Same as table (to be able to read off exact numbers)
		table year cat if leveraged == 1, c(mean FacilityAmt) format(%9.1f)
		
		graph combine A B, graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
				
		graph		export "$path/3_Results/Figure4 (Europe).pdf", replace
		graph		export "$path/3_Results/Figure4 (Europe).png", replace
	
		
		
		
		
		
		
		
		
		
		
