I am trying to write a loop with a macro variable that will change depending on the iterated value of the loop. See the code below.
I want to loop over ticker values "QLD" and "DDM" and i want the local macro index to equal "QQQ" if the ticker is "QLD" otherwise "DIA."
foreach ticker in "QLD" "DDM"{
if `ticker'="QLD"{
local index = "QQQ"
}
else{
local index = "DIA"
}
di `index'
}