Hi,

I am trying to test for potential reverse causality between RTAs using a gravity model.

RTA = 1 if exporter and importer have a RTA at year t.
The pairid is the distance between exporter and importer.

I would like to generate a lead variable capturing the future level of RTAs (in the next 4 years):

tsset pairid year
gen RTA_LEAD4 = f4.RTA
replace RTA_LEAD4 = 0 if RTA_LEAD4 == .



However, I received this error:

tsset pairid year
repeated time values within panel



I think this is because in my database trade flows are treated separately each way (exports and imports) so each pairid of countries is two times each year.

How could I generate the RTA_LEAD4 without changing my pairid?

Thanks!!