Hi all,

This is my first post, so I apologize in advance if anything needs clarification.

I am working on trade flows and have some data for the ReporterCountry, PartnerCountry, T_Product (type of product traded) and year. Here is a working example of my dataset:

Code:
input str3 Rep_country str4 Part_country str2 T_product str4 year
USA CAN X1 2000
FRA AUS X2 2003
RUS EU15 X1 2001
JPN BRA X3 2000
ARG EU15 X2 2004
end
And, I need some help with substituting the observation "EU15" in the variable PartnerCountry by each one of the 15 European countries, keeping all else equal. I mean, for the route RUS-EU15-X1-2001, there would be 15 rows and for each of the 15 rows, RUS will be the reporter country, X1 the product traded, 2001 the year and in the partner_country variable will have to appear AUT in the first row, BEL in the second, and so on.

I have coded some lines but I do not know if my approach is even correct because it reports an error. So any help would be very welcome. Thanks!
Code:
egen id = group(Rep_country Part_country T_product)
sort id
local EU15 AUT BEL DEU DNK ESP FIN FRA GBR GRC IRL ITA LUX NLD PRT SWE
local N : word count `EU15'
expand `N' if Part_country == "EU15"
bys id (year) : gen tag = _n
gen newpartner = .
local EU15 AUT BEL DEU DNK ESP FIN FRA GBR GRC IRL ITA LUX NLD PRT SWE
local N : word count `EU15'
forval i = 1/`N'{
    di `i'
    local new : word `i' of `EU15'
    di "`new'"
    replace newpartner = "`new'" if tag == `i'
}
Code:
1
AUT
type mismatch
r(109);

end of do-file

r(109);