I am trying to run multiple regressions where, on each iteration, another independent variable is added to the regression on each loop?
local vlist0 foo bar dar
local vlist1
foreach item in `vlist0'
[add `item' to `vlist1']
regress dependentVar `vlist1'
I can't seem to find any documentation on appending to local varlists or anything relating to this, so your help is greatly appreciated.
Thanks!
foreach repeatedly sets local macro lname to each element of the list and executes the commands enclosed in braces. The loop is executed zero or more times; it is executed zero times if the list is null or empty.
Some technique:
local vlist0 foo bar dar
local vlist1
foreach item of local vlist0 {
local vlist1 `vlist1' `item'
display "`vlist1'"
}
This appends the contents of the local, along with the new item, to the local itself.
Notice what this really does: redefine local vlist1
each time around the loop. The new definition is the previous definition, plus the new item
.
The first time around the loop vlist1
is empty, but that is not illegal and is well-behaved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With