Hello,
I would like to add _16 to the end of all my variables in my dataset so that when I merge with a DHS data set of a prior year I can differentiate which variables correspond to which year (as the names of the vars are the same across years). I believe I should use a varlist to do so but I'm unsure of the exact code. After reading different posts, I believe it should look something like this:
foreach x of varlist `myvars' {
local y_`x' = regexr("`x'")
rename `x' v_16`x'
}
I successfully created the varlist "myvars" which includes all the variables in my data set, I just need to add the suffix now.
Thanks!
Annalivia
I would like to add _16 to the end of all my variables in my dataset so that when I merge with a DHS data set of a prior year I can differentiate which variables correspond to which year (as the names of the vars are the same across years). I believe I should use a varlist to do so but I'm unsure of the exact code. After reading different posts, I believe it should look something like this:
foreach x of varlist `myvars' {
local y_`x' = regexr("`x'")
rename `x' v_16`x'
}
I successfully created the varlist "myvars" which includes all the variables in my data set, I just need to add the suffix now.
Thanks!
Annalivia
Comment