| clear
|
|
|
|
|
| set matsize 800
|
| clear mata
|
| set mem 500m
|
| set more off
|
| set logtype text
|
| capture log close
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| local folder="GDP"
|
|
|
| insheet using "`folder'\GDP_current_prices.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
|
|
| keep if Measure=="Current prices"
|
|
|
| keep Country Year Value
|
|
|
| rename Value GDP
|
|
|
| rename Country country
|
| rename Year year
|
|
|
|
|
| label var GDP "GDP current prices, Million of national currency"
|
|
|
| save GDP, replace
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| local folder="Financial balance sheets non consolidated SNA 2008"
|
|
|
|
|
|
|
| insheet using "`folder'\Total liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
|
|
| keep if Measure=="National currency, current prices"
|
|
|
| keep Country Sector Time Value
|
|
|
| rename Time Year
|
| rename Value totliab
|
|
|
| gen Sec=""
|
|
|
| replace Sec="Total" if Sector=="Total economy"
|
| replace Sec="World" if Sector=="Rest of the world"
|
| replace Sec="Households" if Sector=="Households and NPISH"
|
| replace Sec="Financials" if Sector=="Financial corporations"
|
| replace Sec="nonFinancials" if Sector=="Non-financial corporations"
|
| replace Sec="Gov" if Sector=="General Government"
|
|
|
| keep if Sec~=""
|
|
|
| keep Country Year Sec totliab
|
|
|
| rename Country country
|
| rename Year year
|
| rename Sec sector
|
| rename totliab totliab_
|
|
|
| reshape wide totliab_, i(country year) j(sector) string
|
|
|
| label var totliab_Total "Tota Liabilities - Total Economy"
|
| label var totliab_World "Tota Liabilities - Rest of the World"
|
| label var totliab_Households "Tota Liabilities - Households and NPISH"
|
| label var totliab_Financials "Tota Liabilities - Financial corporations"
|
| label var totliab_nonFinancials "Tota Liabilities - Non-financial corporations"
|
|
|
| save total_liabilities, replace
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\Financial_Safe_Liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
| keep if Measure=="National currency, current prices" & Sector=="Financial corporations"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="dep" if Transaction=="Currency and deposits"
|
| replace tran="secur" if Transaction=="Debt securities"
|
| replace tran="loan" if Transaction=="Loans"
|
| replace tran="mmf" if Transaction=="Money market fund shares /units"
|
| replace tran="trade" if Transaction=="Trade credits and advances"
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value fin_
|
|
|
| reshape wide fin_, i(country year) j(tran) string
|
|
|
| label var fin_dep "Currency and deposits - Financial corporations"
|
| label var fin_secur "Debt securities - Financial corporations"
|
| label var fin_loan "Loans - Financial corporations"
|
| label var fin_mmf "Money market fund shares /units - Financial corporations"
|
| label var fin_trade "Trade credits and advances - Financial corporations"
|
|
|
|
|
| save financials_safe_items, replace
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\Government_Safe_Liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
| keep if Measure=="National currency, current prices" & Sector=="General Government"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="dep" if Transaction=="Currency and deposits"
|
| replace tran="secur" if Transaction=="Debt securities"
|
| replace tran="loan" if Transaction=="Loans"
|
| replace tran="mmf" if Transaction=="Money market fund shares /units"
|
| replace tran="trade" if Transaction=="Trade credits and advances"
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value gov_
|
|
|
| reshape wide gov_, i(country year) j(tran) string
|
|
|
|
|
| label var gov_dep "Currency and deposits - General Government"
|
| label var gov_secur "Debt securities - General Government"
|
| label var gov_loan "Loans - General Government"
|
| label var gov_mmf "Money market fund shares /units - General Government"
|
| label var gov_trade "Trade credits and advances - General Government"
|
|
|
| save government_safe_items, replace
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\CentralBank_gov_bonds.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
| keep if Measure=="National currency, current prices" & Sector=="Central Bank"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="lbond" if Transaction=="Long-term debt securities"
|
| replace tran="sbond" if Transaction=="Short-term debt securities"
|
|
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value cb_
|
|
|
| reshape wide cb_, i(country year) j(tran) string
|
|
|
| save central_bank_bonds, replace
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\CentralBank_liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
| keep if Measure=="National currency, current prices" & Sector=="Central Bank"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="dep" if Transaction=="Currency and deposits"
|
| replace tran="secur" if Transaction=="Debt securities"
|
| replace tran="loan" if Transaction=="Loans"
|
| replace tran="mmf" if Transaction=="Money market fund shares /units"
|
| replace tran="trade" if Transaction=="Trade credits and advances"
|
| replace tran="totliab_Total" if Transaction=="Financial liabilities"
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value cb_
|
|
|
| reshape wide cb_, i(country year) j(tran) string
|
|
|
|
|
| label var cb_dep "Currency and deposits - Central Bank"
|
| label var cb_secur "Debt securities - Central Bank"
|
| label var cb_loan "Loans - Central Bank"
|
| label var cb_mmf "Money market fund shares /units - Central Bank"
|
| label var cb_trade "Trade credits and advances - Central Bank"
|
| label var cb_totliab_Total "Financial liabilities - Central Bank"
|
|
|
| save cb_safe_items, replace
|
|
|
| clear
|
|
|
| use total_liabilities, replace
|
|
|
| joinby country year using financials_safe_items, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country year using government_safe_items, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country year using central_bank_bonds, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country year using GDP, unmatched(master)
|
| cap drop _merge
|
|
|
| joinby country year using cb_safe_items, unmatched(master)
|
| cap drop _merge
|
|
|
|
|
| foreach var of varlist fin_* gov_* cb_* {
|
| replace `var'=0 if `var'==.
|
| }
|
|
|
| label var cb_lbond "Long-term debt securities held by the central bank"
|
| label var cb_sbond "Short-term debt securities held by the central bank"
|
|
|
|
|
| encode country, gen(countrys)
|
|
|
| drop country
|
| rename countrys country
|
|
|
| tsset country year
|
|
|
| save dataset, replace
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\Total liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
|
|
|
|
|
|
| keep if Measure=="US $, current prices, current exchange rates, end of period"
|
|
|
| keep Country Sector Time Value
|
|
|
| rename Time Year
|
| rename Value totliab
|
|
|
| gen Sec=""
|
|
|
| replace Sec="Total" if Sector=="Total economy"
|
| replace Sec="World" if Sector=="Rest of the world"
|
| replace Sec="Households" if Sector=="Households and NPISH"
|
| replace Sec="Financials" if Sector=="Financial corporations"
|
| replace Sec="nonFinancials" if Sector=="Non-financial corporations"
|
| replace Sec="Gov" if Sector=="General Government"
|
|
|
| keep if Sec~=""
|
|
|
| keep Country Year Sec totliab
|
|
|
| rename Country country
|
| rename Year year
|
| rename Sec sector
|
| rename totliab totliab_
|
|
|
| reshape wide totliab_, i(country year) j(sector) string
|
|
|
| label var totliab_Total "Tota Liabilities - Total Economy"
|
| label var totliab_World "Tota Liabilities - Rest of the World"
|
| label var totliab_Households "Tota Liabilities - Households and NPISH"
|
| label var totliab_Financials "Tota Liabilities - Financial corporations"
|
| label var totliab_nonFinancials "Tota Liabilities - Non-financial corporations"
|
|
|
| save total_liabilitiesUSD, replace
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\Financial_Safe_Liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
|
|
| keep if Measure=="US $, current prices, current exchange rates, end of period"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="dep" if Transaction=="Currency and deposits"
|
| replace tran="secur" if Transaction=="Debt securities"
|
| replace tran="loan" if Transaction=="Loans"
|
| replace tran="mmf" if Transaction=="Money market fund shares /units"
|
| replace tran="trade" if Transaction=="Trade credits and advances"
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value fin_
|
|
|
| reshape wide fin_, i(country year) j(tran) string
|
|
|
| label var fin_dep "Currency and deposits - Financial corporations"
|
| label var fin_secur "Debt securities - Financial corporations"
|
| label var fin_loan "Loans - Financial corporations"
|
| label var fin_mmf "Money market fund shares /units - Financial corporations"
|
| label var fin_trade "Trade credits and advances - Financial corporations"
|
|
|
|
|
| save financials_safe_itemsUSD, replace
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\Government_Safe_Liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
|
|
| keep if Measure=="US $, current prices, current exchange rates, end of period"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="dep" if Transaction=="Currency and deposits"
|
| replace tran="secur" if Transaction=="Debt securities"
|
| replace tran="loan" if Transaction=="Loans"
|
| replace tran="mmf" if Transaction=="Money market fund shares /units"
|
| replace tran="trade" if Transaction=="Trade credits and advances"
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value gov_
|
|
|
| reshape wide gov_, i(country year) j(tran) string
|
|
|
|
|
| label var gov_dep "Currency and deposits - General Government"
|
| label var gov_secur "Debt securities - General Government"
|
| label var gov_loan "Loans - General Government"
|
| label var gov_mmf "Money market fund shares /units - General Government"
|
| label var gov_trade "Trade credits and advances - General Government"
|
|
|
| save government_safe_itemsUSD, replace
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\CentralBank_gov_bonds.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
|
|
| keep if Measure=="US $, current prices, current exchange rates, end of period"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="lbond" if Transaction=="Long-term debt securities"
|
| replace tran="sbond" if Transaction=="Short-term debt securities"
|
|
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value cb_
|
|
|
| reshape wide cb_, i(country year) j(tran) string
|
|
|
| save central_bank_bondsUSD, replace
|
|
|
|
|
|
|
|
|
| clear
|
|
|
| insheet using "`folder'\CentralBank_liabilities.csv", n c case
|
|
|
| des
|
|
|
| tab PowerCode
|
| tab Measure
|
| tab Transaction
|
| tab Sector
|
|
|
|
|
| keep if Measure=="US $, current prices, current exchange rates, end of period"
|
|
|
| keep Country Time Transaction Value
|
|
|
| gen tran=""
|
|
|
| replace tran="dep" if Transaction=="Currency and deposits"
|
| replace tran="secur" if Transaction=="Debt securities"
|
| replace tran="loan" if Transaction=="Loans"
|
| replace tran="mmf" if Transaction=="Money market fund shares /units"
|
| replace tran="trade" if Transaction=="Trade credits and advances"
|
| replace tran="totliab_Total" if Transaction=="Financial liabilities"
|
|
|
| drop if tran==""
|
|
|
| keep Country Time tran Value
|
| rename Country country
|
| rename Time year
|
| rename Value cb_
|
|
|
| reshape wide cb_, i(country year) j(tran) string
|
|
|
|
|
| label var cb_dep "Currency and deposits - Central Bank"
|
| label var cb_secur "Debt securities - Central Bank"
|
| label var cb_loan "Loans - Central Bank"
|
| label var cb_mmf "Money market fund shares /units - Central Bank"
|
| label var cb_trade "Trade credits and advances - Central Bank"
|
| label var cb_totliab_Total "Financial liabilities - Central Bank"
|
|
|
| save cb_safe_itemsUSD, replace
|
|
|
|
|
|
|
| clear
|
|
|
| use total_liabilitiesUSD, replace
|
|
|
| joinby country year using financials_safe_itemsUSD, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country year using government_safe_itemsUSD, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country year using central_bank_bondsUSD, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country year using cb_safe_itemsUSD, unmatched(both)
|
| cap drop _merge
|
|
|
|
|
|
|
| foreach var of varlist fin_* gov_* cb_* {
|
| replace `var'=0 if `var'==.
|
| }
|
|
|
| label var cb_lbond "Long-term debt securities held by the central bank"
|
| label var cb_sbond "Short-term debt securities held by the central bank"
|
|
|
|
|
| encode country, gen(countrys)
|
|
|
| drop country
|
| rename countrys country
|
|
|
| tsset country year
|
|
|
| save datasetUSD, replace
|
|
|
|
|
|
|
| use datasetUSD, clear
|
|
|
|
|
| gen fin_safeUSD=fin_dep+fin_loan+fin_mmf+fin_secur
|
| gen cb_safeUSD=cb_dep+cb_loan+cb_mmf+cb_secur
|
|
|
|
|
| gen gov_safeUSD=gov_dep+gov_loan+gov_mmf+gov_secur
|
|
|
|
|
| rename totliab_Total totliab_TotalUSD
|
|
|
| keep country year fin_safeUSD gov_safeUSD cb_safeUSD totliab_TotalUSD
|
|
|
| sort country year
|
| tsset country year
|
|
|
|
|
| save safeUSD, replace
|
|
|
|
|
|
|
| use safeUSD, clear
|
|
|
| gen tempvar=fin_safeUSD+gov_safeUSD+totliab_TotalUSD
|
|
|
| bysort country: egen minyear=min(year) if tempvar<.
|
| bysort country: egen maxyear=max(year) if tempvar<.
|
|
|
| keep if minyear<=1995
|
| keep if year>=1995
|
|
|
| keep if maxyear>=2017
|
| keep if year<=2017
|
|
|
| sort country year
|
| tsset country year
|
|
|
|
|
| if r(balanced)!="strongly balanced" {
|
| di "WARNING!!!! panel is not balanced"
|
| }
|
|
|
| preserve
|
|
|
| keep if year==2017
|
|
|
| keep country
|
|
|
| gen OECD=1
|
|
|
| save OECD, replace
|
|
|
| restore
|
|
|
|
|
| decode country, g(country_name)
|
|
|
| bysort year: egen fin_safeWorld=total(fin_safeUSD)
|
| bysort year: egen gov_safeWorld=total(gov_safeUSD)
|
| bysort year: egen new_totalWorld=total(totliab_TotalUSD)
|
|
|
| bysort year: egen cb_safeWorld=total(cb_safeUSD)
|
|
|
| gen fin_shareWorld=fin_safeWorld/new_totalWorld
|
| gen gov_shareWorld=gov_safeWorld/new_totalWorld
|
| gen shareWorld=fin_shareWorld+gov_shareWorld
|
|
|
| gen cb_shareWorld=cb_safeWorld/new_totalWorld
|
|
|
| bysort year: egen fin_safeNonUS=total(fin_safeUSD) if country_name!="United States"
|
| bysort year: egen gov_safeNonUS=total(gov_safeUSD) if country_name!="United States"
|
| bysort year: egen new_totalNonUS=total(totliab_TotalUSD) if country_name!="United States"
|
|
|
| bysort year: egen cb_safeNonUS=total(cb_safeUSD) if country_name!="United States"
|
|
|
| gen fin_shareNonUS=fin_safeNonUS/new_totalNonUS
|
| gen gov_shareNonUS=gov_safeNonUS/new_totalNonUS
|
| gen shareNonUS=fin_shareNonUS+gov_shareNonUS
|
|
|
| gen cb_shareNonUS=cb_safeNonUS/new_totalNonUS
|
|
|
| sort country year
|
|
|
| keep if country==country[1]
|
|
|
| keep fin_shareWorld gov_shareWorld shareWorld cb_shareWorld fin_shareNonUS gov_shareNonUS shareNonUS cb_shareNonUS year
|
|
|
|
|
| keep year fin_shareWorld gov_shareWorld shareWorld cb_shareWorld fin_shareNonUS gov_shareNonUS shareNonUS cb_shareNonUS
|
|
|
| save World, replace
|
|
|
|
|
|
|
|
|
| use dataset
|
|
|
| joinby country year using safeUSD, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby year using World, unmatched(both)
|
| cap drop _merge
|
|
|
| joinby country using OECD, unmatched(both)
|
| cap drop _merge
|
|
|
| cap drop fin_safe
|
| cap drop cb_safe
|
|
|
| label var gov_safeUSD "government safe liabilities in USD"
|
| label var fin_shareWorld "financial liabilities (as share of total assets) for the whole world"
|
| label var gov_shareWorld "government liabilities (as share of total assets) for the whole world"
|
| label var cb_shareWorld "central bank liabilities (as share of total assets) for the whole world"
|
| label var shareWorld "safe liabilities (as share of total assets) for the whole world"
|
|
|
| label var fin_shareNonUS "financial liabilities (as share of total assets) for non-US sample"
|
| label var gov_shareNonUS "government liabilities (as share of total assets) for non-US sample"
|
| label var cb_shareNonUS "central bank liabilities (as share of total assets) for non-US sample"
|
| label var shareNonUS "safe liabilities (as share of total assets) for non-US sample"
|
|
|
| label var totliab_Gov "Tota Liabilities - Government"
|
| label var OECD "dummy for OECD countries"
|
|
|
| save OECD_data, replace
|
|
|
|
|