Dear Stata users,
I am trying to figure out how to solve the following problem:
I have bilateral variables (called agreement_1, agreement_2, etc.) that equals 1 when two countries belong to the same agreement. However, I would like to have a dummy variable that indicates whether the second country belongs to a specific agreement no matter if its partner country (country 1) belongs to the agreement or not.
Here is an example:
So I want to have a unilateral variable (called agreement_1_country2) which will equal 1 for the first, third and fourth line, meaning whenever the country2 is RWA or BDI since we know that these countries belong to the agreement_1.
I was thinking of using the command tab to obtain all the distinct values for country2:
but then I don't know what to eventually create the new variable agreement_1_country2.
One thing I want to add, is that I don't necessarily need to generate the unilateral variable in my database, I just need it in memory to create additional variables later in my code using this unilateral variable as a condition.
Thank you in advance.
Marie
I am trying to figure out how to solve the following problem:
I have bilateral variables (called agreement_1, agreement_2, etc.) that equals 1 when two countries belong to the same agreement. However, I would like to have a dummy variable that indicates whether the second country belongs to a specific agreement no matter if its partner country (country 1) belongs to the agreement or not.
Here is an example:
Code:
input str3 country1 str3 country2 agreement_1 agreement_2 "BDI" "RWA" 1 0 "BDI" "ZAF" 0 1 "FRA" "RWA" 0 0 "RWA" "BDI" 1 0 end
I was thinking of using the command tab to obtain all the distinct values for country2:
Code:
tab country2 if agreement_1 == 1
One thing I want to add, is that I don't necessarily need to generate the unilateral variable in my database, I just need it in memory to create additional variables later in my code using this unilateral variable as a condition.
Thank you in advance.
Marie
Comment