Dear Statalist community,
I have a panel dataset with the following variables:
id year country_a country_b FTA
id uniquely identifies my dyad (pair of country_a and country_b). I have 150 countries, thus 150*(150-1)/2 = 11175 unique dyads (pairings) and therefore 11175 observations per year. This means, the observation country pair ij exists, but country pair ji does not exist in my dataset. For example, country pair AUS USA is included, but USA AUS not (because AUS comes first in alphabetical order).
FTA is a dummy variable, that equals 1 if country_a has a free trade agreement with country_b.
Now I want to generate a new variable that stores the sum of all FTAs that country_a has with other countries than country_b. I tried the following code which is obviously wrong:
How can I get (for each id and each year) the sum of all FTAs that country_a has with other countries than country_b? I would also need a variable with the sum of FTAs that do not include the countries of the country pair in that observation, again per id and year?
Could you please help me out here?
Thank you,
Thomas
I have a panel dataset with the following variables:
id year country_a country_b FTA
id uniquely identifies my dyad (pair of country_a and country_b). I have 150 countries, thus 150*(150-1)/2 = 11175 unique dyads (pairings) and therefore 11175 observations per year. This means, the observation country pair ij exists, but country pair ji does not exist in my dataset. For example, country pair AUS USA is included, but USA AUS not (because AUS comes first in alphabetical order).
FTA is a dummy variable, that equals 1 if country_a has a free trade agreement with country_b.
Now I want to generate a new variable that stores the sum of all FTAs that country_a has with other countries than country_b. I tried the following code which is obviously wrong:
Code:
bysort country_a year: egen newvar1 = total(FTA) gen newvar2=newvar1-FTA
Could you please help me out here?
Thank you,
Thomas
Comment