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
IV estimation (2SLS) with slope dummy variable interacting with endogenous variable.Hi, I want to estimate a regression with a dummy variable, say D. My dependent variable is Y. My exo…
Cross sectional dependency in panel dataHello, I am working on a panel data of six Emerging economies with quarterly data from 2000-2020. S…
Get name of specific variable which name is equal to another value of a variableI have a study where I am to look 28 days back in time before an event to see if the patients were w…
loop for missing valuesHi everyone! I am trying to complete a database in form of a "tree", adding as values the last avail…
keep the last observation(s) in each yearDear All, Suppose that the data set is Code: * Example generated by -dataex-. To install: ssc insta…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming multiple variables in a loop
Post a Comment