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
Invalid syntax; not obvious what is wrong.Dear All, I have a 7 year state panel of US states: Code: Code: * Example generated by -dataex-. …
Clustering SE in an Instrumental Variable (IV) regression yields to negative effects compared to "unclustered" IV regression - How's that?Hello today I performed an IV regression with two instruments. Both instruments are indicator vari…
how to create a categorical dummy from a group of dummy variablesHi everyone, I want to create a categorical dummy called Engagement, which should take its values f…
Specification of Known Latent Classes using gsem lclassDear StataList, I am using Stata 14 on a Mac OS Yosemite 10.10.5. I am trying to use gsem to weight…
Create new variable with new data in current datasetHi I have seen many posts with similar questions, but not one that I think completely fits my proble…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming variables using the 'foreach' command
Post a Comment