Based on this post in the Stata forum, I have been able to rename all variables containing a dot "." with an underscore thanks to Joseph Coveney. Funnily enough for the same dataset, the Latinobarometer 2018, I now want to repeat the command, this time for the labels as they also contains dots.
I have tried to modify the code from the original post, unfortunately unsuccessful.
Original code:
My attempt, which does not work:
I have tried to modify the code from the original post, unfortunately unsuccessful.
Original code:
Code:
foreach varname of varlist * {
local ++i
if ( "`varname'" != ustrtoname("`varname'") ) {
mata : st_varrename(`i', ustrtoname("`varname'") )
}
}
Code:
foreach label of label dir * {
local ++i
if ( "`varname'" != ustrtoname("`label'") ) {
mata : st_varrename(`i', ustrtoname("`label'") )
}
}


Comment