I have a database on bilateral trade between 35 countries, so I have 1190 obs (35 countries * 34 possible partners). One of my variables is called PARTNER, which consists of the names of the countries. I am running a multiple regression with a dummy variable for each "PARTNER", using the following code:
encode PARTNER, gen(PARTNERCODE)
reg logconsrat1 i.PARTNERCODE logdist Commlang Colrel Contig, r
I now have a coefficient for each of the 34 dummy variables included in the regression, and I would like to store them in a new variable called "S", in which the coefficient is asigned to a certain observation depending on its "PARTNERCODE".
I have tried using a loop, using the following code:
reg logconsrat1 i.PARTNERCODE logdist Commlang Colrel Contig, r
postfile S (PARTNERCODE) using filename, replace foreach pcode of numlist 1/35 {
replace S = _b[i.PARTNERCODE`pcode'] if PARTNERCODE == `pcode'
}
postclose
But i am obtaining an error message stating "( invalid name" after the second line.
What should I do?
encode PARTNER, gen(PARTNERCODE)
reg logconsrat1 i.PARTNERCODE logdist Commlang Colrel Contig, r
I now have a coefficient for each of the 34 dummy variables included in the regression, and I would like to store them in a new variable called "S", in which the coefficient is asigned to a certain observation depending on its "PARTNERCODE".
I have tried using a loop, using the following code:
reg logconsrat1 i.PARTNERCODE logdist Commlang Colrel Contig, r
postfile S (PARTNERCODE) using filename, replace foreach pcode of numlist 1/35 {
replace S = _b[i.PARTNERCODE`pcode'] if PARTNERCODE == `pcode'
}
postclose
But i am obtaining an error message stating "( invalid name" after the second line.
What should I do?
Comment