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 variable for other events in same region/yearHi everyone! I am dealing with a worldwide data set on conflict events with an unbalanced panel str…
Create stata time variableHi Stata Users, I have data in the form 01.01.2019 and want Stata to use it as time variable I tri…
Working with Dates in Panel DataI'm trying to compute and incidence case based on test_1. So an incident case will be a positive tes…
General question about Cox regressionI have a group of patients that have stopped taking treatment at one health facility (say Facility A…
CreatingBar GraphHello, I need to make a graph showing average expenditure for income quartiles, differing by househ…
Subscribe to:
Post Comments (Atom)
0 Response to add different suffixes to 1500+ variable names using foreach
Post a Comment