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
Related Posts with Renaming multiple variables in a loop
What does "adj" in this code mean?I faced a code a below and I do not understand what does adj mean here Code: predict adj, residual…
Foreach loop does not computeHello all, I am currently analyzing survey data where I have data on e.g. the expected unemployment…
Row names with esttab using over()Hi all, I'm using Stata 17 and the user-written esttab command from SSC to create/export tables to …
How to subtract within a column based on criteria from other columns?Hi, I have the following variables in my dataset: ID, group, nnid1, TRT, OUTCOME There are two gro…
AUC in cutpt vs roctabGood morning, I use . cutpt to calculate cut points (reference ranges) for laboratory diagnostic met…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming multiple variables in a loop
Post a Comment