Hi,
I want to rename all the variables of my data set erasing the last 2 digits of each variable name. I saw a post from Nick Cox answering this question but his code does not seem to work for me.
The code I am running is:
foreach var of varlist * {
local newname = substr(`var', 1, length(`var')-2)
rename `var' `newname'
}
When I run it Stata says "type mismatch". Do you know what seems to be the problem?
I want to rename all the variables of my data set erasing the last 2 digits of each variable name. I saw a post from Nick Cox answering this question but his code does not seem to work for me.
The code I am running is:
foreach var of varlist * {
local newname = substr(`var', 1, length(`var')-2)
rename `var' `newname'
}
When I run it Stata says "type mismatch". Do you know what seems to be the problem?
Comment