Dear Forum,
I intensely follow the Statalist debate around how to best run 2 parallel loops in Stata. The below shown command seems like the way to go if I want to run a loop which does not execute over all possible 9 combinations in this example of 2 lists of variables with 3 variables each, but only does A-1 B-2 C-3
Question1: Is this the correct code for running a parallel loop?
Question2: I have actually significantly more variables which I want to use in the locals Returns and Market_Cap, i.e. more than 1000 each. I don`t want to list them all by hand an the command 1 - 1000. which should refer to all variables from 1 UNTIL 1000 does not work for local macros. Is there an efficient way to refer to such a long list of variables using local macros or do I have to alter the aforementioned parallel loop formula?
Thanks a lot for any help!!
I intensely follow the Statalist debate around how to best run 2 parallel loops in Stata. The below shown command seems like the way to go if I want to run a loop which does not execute over all possible 9 combinations in this example of 2 lists of variables with 3 variables each, but only does A-1 B-2 C-3
Code:
local Returns 10 20 30 local Market_Cap 1 2 3 local n : word count `marketcaps' forvalues i = 1/`n' { local a : word `i' of `Returns' local b : word `i' of `Market_Cap' gen TEST_`a'_`b'=`a'+`b' }
Question2: I have actually significantly more variables which I want to use in the locals Returns and Market_Cap, i.e. more than 1000 each. I don`t want to list them all by hand an the command 1 - 1000. which should refer to all variables from 1 UNTIL 1000 does not work for local macros. Is there an efficient way to refer to such a long list of variables using local macros or do I have to alter the aforementioned parallel loop formula?
Thanks a lot for any help!!
Comment