/********Stata code used produce full set of appendix figures and tables***/
/*****series using 57 core territories: 48 countries + 9 subregions**/

#delimit;
clear all;
set more off;
set maxvar 6000;
do code/doglobalvariables.txt;


/****series on gross trade flows (goods)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("C1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A3b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("C1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A3c", modify) cell(B5) keepcellfmt;
/****series on gross trade flows (primary commodities)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("K1d") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A4b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("K1e") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A4c", modify) cell(B5) keepcellfmt;
/****series on gross trade flows (manufactured goods)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("K2d") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A5b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("K2e") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A5c", modify) cell(B5) keepcellfmt;
/****series on gross trade flows (services)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("D1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A6b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("D1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A6c", modify) cell(B5) keepcellfmt;
/****series on gross income flows***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("E1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A7b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("E1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A7c", modify) cell(B5) keepcellfmt;
/****series on gross transfer flows***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("F1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A8b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("F1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("A8c", modify) cell(B5) keepcellfmt;
/****series on current account***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("H1a") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("B1a", modify) cell(B5) keepcellfmt;
/****series on net foreign wealth***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("I1a") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("C1a", modify) cell(B5) keepcellfmt;
/****series on trade balance (goods)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("C1a") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("D1a", modify) cell(B5) keepcellfmt;
/****series on trade balance (primary commodities)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("K1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("D3a", modify) cell(B5) keepcellfmt;
/****series on trade balance (manufactured goods)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("K2c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("D5a", modify) cell(B5) keepcellfmt;
/****series on trade balance (services)***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("D1a") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("E1a", modify) cell(B5) keepcellfmt;
/****series on income balance***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("E1a") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("F1a", modify) cell(B5) keepcellfmt;
/****series on transfer balance***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("F1a") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("G1a", modify) cell(B5) keepcellfmt;
/****series on gross foreign assets and liabilities***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("I1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("I1a", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("I1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("I2a", modify) cell(B5) keepcellfmt;
/****series on rates of return to gross foreign assets and liabilities***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("J1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("I3a", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("J1c") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("I3b", modify) cell(B5) keepcellfmt;
/***series on nominal GDP, exchange rates, etc.***/
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("B1b") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("K1a", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("B1d") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("K2a", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("B1x") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("K3a", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("B1xr") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("K3b", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("B1px") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("K3c", modify) cell(B5) keepcellfmt;
import excel NievasPiketty2025AppendixHistorical.xlsx, sheet("A1") cellrange(B5:BO228) clear;
export excel using NievasPiketty2025AppendixFigures.xlsx, sheet("K4a", modify) cell(B5) keepcellfmt;