Colleagues,
I'm trying to remove a set of characters from the middle of variable name. Following previous discussions, I'm trying the following code but I keep on getting the type mismatch error.
Fixed, the inverted commas were missing.
I'm trying to remove a set of characters from the middle of variable name. Following previous discussions, I'm trying the following code but I keep on getting the type mismatch error.
Code:
foreach var of varlist somevariablename22 - somevariablename89 {
local newname = substr(`var',13,length(`var') - 4)
rename `var' `newname'
}
Fixed, the inverted commas were missing.
Code:
foreach var of varlist somevariablename22 - somevariablename89 {
local newname = substr("`var'",13,length("`var'") - 4)
rename `var' `newname'
}

Comment