Hi.
I have this problem I have been trying to solve to no avail. Basically, I'm running these loops that need to have the variables as local macros. I keep getting an ambiguous abbreviation error that I can't figure out.
Variables in my data
elast
coef_var1 through coef_var5
There are other variables in my data like coef_se_var1 through 5, as well.
So I first define my macros:
local elastvar elast_`i'
local coef coef_var`i'
local sumelast elast_*
Then, I run a loop that iterates through each of the 1 through 5 suffixes:
foreach i in 1 2 3 4 5 {
gen elastvar = 0
replace `elastvar' = (`coef'*avg)/avgprice if intx_var`i'=="NA"
replace `elastvar' = (`coef'*avg*size)/price if intx_var`i'=="area"
replace `elastvar' = (`coef'*avg*dist)/price if intx_var`i'=="linear"
replace `elastvar'= 0 if `elastvar'==.
}
I get an error that reads coef_var ambiguous abbreviation. Does anyone have any suggestions?
I have this problem I have been trying to solve to no avail. Basically, I'm running these loops that need to have the variables as local macros. I keep getting an ambiguous abbreviation error that I can't figure out.
Variables in my data
elast
coef_var1 through coef_var5
There are other variables in my data like coef_se_var1 through 5, as well.
So I first define my macros:
local elastvar elast_`i'
local coef coef_var`i'
local sumelast elast_*
Then, I run a loop that iterates through each of the 1 through 5 suffixes:
foreach i in 1 2 3 4 5 {
gen elastvar = 0
replace `elastvar' = (`coef'*avg)/avgprice if intx_var`i'=="NA"
replace `elastvar' = (`coef'*avg*size)/price if intx_var`i'=="area"
replace `elastvar' = (`coef'*avg*dist)/price if intx_var`i'=="linear"
replace `elastvar'= 0 if `elastvar'==.
}
I get an error that reads coef_var ambiguous abbreviation. Does anyone have any suggestions?
Comment