Dear all,
I have been trying to add different suffixes (numbers) to a set of variables named v1, v2, v3... but my code seems not working. The suffixes come from the variable id. Namely, I want to rename my variables as follows:
v1 ==> d_1101506022
v2 ==> d_1101506032
v3 ==> d_1101506073
.
.
.
My code is as follows:
foreach x in v* {
local var = id
local suffix = `var'[`_n']
rename `x' d_`suffix'
}
Will you please tell me what I am doing wrong? Thank you
Array
Related Posts with add different suffixes to 1500+ variable names using foreach
Creating own table in StataHi, Slightly strange request but I am doing some analysis and tabulations for one of my colleagues …
A multilevel model succeeds in STATA but fails in RHi, I fit a simple variance component multilevel model with a large longitudinal dataset (obs>60…
changing working directoryHi everyone, I recently updated to Stata 15. In the main window, I used to be able to change the wo…
Checking for Missing Head of Houshold within a householdHello, I have a data set on household survey where the household size, member of the household numbe…
Group identifier for individual panels: repeated time values within panelHi all, I'm hoping to be able to get some guidance on a work-around for the repeated time values wi…
Subscribe to:
Post Comments (Atom)
0 Response to add different suffixes to 1500+ variable names using foreach
Post a Comment