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
Changing data based on conditionHi, I am using Stata 15 on Windows 10 OS. I have data collected in several rounds as demonstrated i…
Alternative to tobit regression for left-censored biomarker variableHi, I'm a novice when it comes to stats so apologies if the question is a bit stupid! I'm currentl…
about odds,why the two command get the different results?a list of numbers,as follows drug used unused case 55 128 control 19 164 when use co…
How to Create a Twoway Graph with a few lines of quantile PlotGood morning everyone, I am a newbie, Could anyone please help me with how to create a Twoway Graph…
Estimate utility from going to school - Discrete choice model.Hello, I need to estimate utility from going to school in a discrete choice model. In the dataset,…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming variables using the 'foreach' command
Post a Comment