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
why categorical variables regression only shows one group result?Hey, I am running a regression with categorical variables. But I am quite confused why it only show…
bootstrap test for a multilevel mediation analysisDear all, I'm trying to perform a 2-2-1 multilevel analysis, and my DV is binary. I used the comman…
Using loops to create local from other localsI tell Stata that: Code: local 1 "a b c" local 2 "d e f" local 3 "g h i" and I want it to create t…
creating loopHi, I am new in stata, so I am doing long commands for a simple variable generating. I want to short…
Problem in reporting Arellano-Bond test for auto-correlation after xtabond2Hello dear Stata Users, I am estimating a dynamical panel (370 firms; T=10) where my dependent var i…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming variables using the 'foreach' command
Post a Comment