I am trying to rename multiple variables corresponding to baseline characteristics, endline characteristics and endline2 characertistics into wave1 wave2 and wave3 so that I can reshape the data into a long format based on these three time periods.
I used the following codes however it does not seem to work despite multiple tries at reformatting it, STATA gives me an error message everytime:
local vars "asset_tot_value iagri_month ibusiness_month ipaidlabor_month ranimals_month ctotal_pcmonth"
foreach k of local vars {
rename `k'_bsl `k'1
rename `k'_end `k'2
rename `k'_fup `k'3
}
Is there something wrong with how I am coding this?
Related Posts with Renaming variables using the 'foreach' command
Competing risk survival analysisHello, I am approaching for the first time a competing risk survival analysis. I am using Stata/SE …
Generate New Variable Only For Certain DataHi all, I tried searching for this and I just can't find the exact answer. It seems like this shoul…
Unbalanced Panel DataHi everyone, I have the following unbalanced panel data which stands from year 2000 to 2019: ID …
How to sum two variables from different observations of the same categoryHello together, I have a data set with companies, which conduct deals. Furthermore, these deals hav…
Help with converting string to numeric variablesI have a dataset on infant and child ages, where age is stored as a string variable and by week,mont…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming variables using the 'foreach' command
Post a Comment