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
Compute Estimated Hazard and Plot Estimated Hazard Curve after Fitting a xtmelogit Survival Model in StataThe dataset is presented below, insheet using "https://ift.tt/aXA9elG", comma foreach i of varlist …
"variable at_exp_share11 already defined" is always displayed when I run the command."variable at_exp_share11 already defined" is always displayed when I run the command. But I can conf…
Number of Estimated Coefficients in a RegressionIs there a way to display the number coefficients estimated in a regression? I am estimating differe…
Creating Variable and Dummy Variable Based on Condition Met in Each YearI am trying to create dummy variable based on conditions met in each the year - I will have two vari…
Undisplayed dates: weekends, public holidays, and other reasonsHi I have a dataset that includes daily observations and a daily date variable (DATE). Some dates a…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming multiple variables in a loop
Post a Comment