Hi,
How can I rename multiple variables without having to manually rename every single one of them using a loop? I am using the following formula but I get an error:
. local a " qq01 qq02 qq03 qq04 qq05 qq06 qq07 qq08a qq08b qq09a qq09b"
. local b "qq_old01 qq_old02 qq_old03 qq_old04 qq_old05 qq_old06 qq_old07 qq_old08a qq_old8b qq_old9a qq_old9b"
. foreach x of varlist `a' {
2. rename `x' `b'
3. }
syntax error
Syntax is
rename oldname newname [, renumber[(#)] addnumber[(#)] sort ...]
rename (oldnames) (newnames) [, renumber[(#)] addnumber[(#)] sort ...]
rename oldnames , {upper|lower|proper}
Best,
Shehryar
A new STATA user
0 Response to Renaming multiple variables in a loop
Post a Comment