Hi,
I am having a hard time to loop over a string (not a variable) in order to manipulate a variable defined by the string. Please help.
Here is what I have:
I am having a hard time to loop over a string (not a variable) in order to manipulate a variable defined by the string. Please help.
Here is what I have:
Code:
sysuse auto, clear
local factors displacement gear_ratio foreign
foreach var in `factors' {
gen r_`var'=`var'/100
}
drop displacement gear_ratio foreign
foreach var in `factors' {
replace r_`var'=`var'/100
}

Comment