# Replication Package — How to Buy a Trade Surplus

**Authors:** Joseph E. Gagnon & Nishtha Agrawal
**Last updated:** June 2026


This package reproduces all tables, figures, and footnote/in-text numbers in the paper. All analysis is done in Stata using `master.do`, which runs every step in order.

---

## 1. How to run

1. Download the package and keep the folder structure intact.
2. Open `master.do` and edit the single line in Section 1:
   ```
   global root "C:/path/to/replication_package"
   ```
3. Run the whole pipeline:
   ```
   do "master.do"
   ```
4. Results appear in `output/tables/` and `output/figures/`.

To run only part of the pipeline, set the switches near the top of `master.do` (`run_build`, `run_tables`, `run_figures`, `run_notes`) to `0`/`1`.

```

---

## 2. Pipeline (order of execution)

| Step | Do-file | What it does | Reads | Writes |
|------|---------|--------------|-------|--------|
| 1 | `01_regpanel.do` | Builds the regression panel | `data/intermediate/` | `data/final/` |
| 2 | `02_crosscountry.do` | Builds the cross-country dataset | `data/intermediate/` or `data/final/` | `data/final/` |

---

## 3. Code → exhibit crosswalk

| Exhibit in paper | Do-file | Output file |
|------------------|---------|-------------|
| Table 1 | `02_tables/table_1.do` | `output/tables/[name]` |
| Table 2 | `02_tables/table_2.do` | `output/tables/[name]` |
| Table 3 | `02_tables/table_3.do` | `output/tables/[name]` |
| Table 4 | `02_tables/table_4.do` | `output/tables/[name]` |
| Figures 1 & 2 | `03_figures/fig_1_2.do` | `output/figures/[name]` |
| Figure 3 | `03_figures/fig_3.do` | `output/figures/[name]` |






