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
Using teffects psmatch, is it possible to display the logistic treatment model used to generate the propensity scores?When using teffects psmatch, is it possible to display the logistic treatment model used by teffects…
coefficients for covariates under inverse probability weighting modelHello, i know Code: teffects ipw or Code: teffects ipwra estimate the treatment effect on the …
Estimation of censored valueDear All, Situation: I have some biological variables containing left censored observation (below t…
identify years of violations.Dear All, I find this question here (https://bbs.pinggu.org/forum.php?mod...=1#pid56831974). The dat…
forvalues: unexpected value of a looping local: 81/100=.8100000000000001Dear Stata list users, I want to loop over values d=0(0.01)0.2 and d2= 0.80(0.01)1 I already know t…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming multiple variables in a loop
Post a Comment