Hii, this is just a preliminary analysis before performing a PPML estimation based on gravity equation in PANEL data setting (interval of 5 years) Using STATA17.

variables:
t=year (1995-2019)
i= exporter-id
j=importer-id
k2=2 digi HS code
export=export values current price in $.

Assume that you have a trade deal, signed between i and j in a
particular year, which we denote as t=1. Then we would look at 5 years
before, and 5 years from the agreement onward, to see what are the
trade volume between them in comparison to the trade with others.
Namely, we would compare {export from i, to all the countries which
never had any agreement with i}, with {export from i, to j}, from year
t=(-4) to t=(+5).

For each pair of (i, j). You can aggregate the total trade from i to
the nodeal countries, and to j, for these 11 years. Assume they are
the following:
EX(ij, -4), EX(ij, -3), ..., EX(ij,+5), and
EX(io, -4), EX(io, -3), ..., EX(io, +5). ("o" represents all the
countries that never had any trade agreement with).

We express everything as "the change from t=0", i.e. the year
immediately before the agreement entering into force, so to calculate
the following two series:
EX(ij,-4)/EX(ij, 0), EX(ij,-3)/EX(ij, 0), .... EX(ij, 0)/EX(ij,0)=1,
... EX(ij, +5)/EX(ij,0),
and same for EX(io, t), everything number divided by EX(io, 0).

So here you end up in 2 series, representing the change of trade
(taking the benchmark year t=0) for either the total export to j, or
total export to all no-deal countries.

Divide these two series then you would see how the export growth to j
is compared with export growth to the non-deal countries: i.e.
[EX(ij,-4)/EX(ij, 0)] / [EX(io,-4)/EX(io, 0)], ... and for years from -4 to +5.

One would expect that the pattern of trade with j would be similar
with other no-deal countries when there was no deal, so one won't
expect the indicator above to be very different from 1 for years -4 to
-1 (for year=0 it is by construction equal to 1). But for the years
after the trade agreement has been signed, one would expect that
export growth to j will be larger than the export growth to the
no-deal countries, so the series should be visibly larger than 1 for
the years 12345.

Now, I have put the data for each i-j into one set, and still have to implement all agreements from the WTO-IS database on trade agreements.
However, this dataset has totally different settings. Furthermore, I have created the data is such a way that exports are given in 2 digit HS codes. I eventually want to be able to analyse whether the manufacturing share if exports in developing countries increased due to trade agreements, however in the data I need to create this somehow. Finally, I am not really used to working with STATA so that I do not know the specific codes for the equation I mentioned above. Can any one help me with the follwing questions?

1. How do I merge trade agreements from the last 25 years into the dataset, using year specific dates into entry force from the WTO-IS? Do I have to create a dummy variable and replace every value of 0, for each agreement?
2. Is there a quick way of creating a dummy variable of whether a country (UN numerical codes) are developing or developed?
3. Does anyone know where to draw the line in HS 2 digit codes whether export products are manufacturing or primary output?
4. How to create a variable with values for each country pair (i-->j) in year 't' with total export and manufacturing share of exports?
5. How to merge all other values of 2-digit HS codes to clean up the dataset?
6. How to code the equation mentioned above?
7. How to show the difference in export structure?

I would already be very happy if some of you can help me with one of the above, since I feel there is just too many options in STATA so I don't know where to begin. I see the beauty of the program, I have have to find out how to swim in this big blue ocean of options. Thanks in advance.

https://isge2018.isgesociety.com/reg...ing-countries/
https://rtais.wto.org/UI/PublicAllRTAList.aspx
https://comtrade.un.org/data/cache/reporterAreas.json