Dear everyone,

I would like to know if someone knows a STATA code that I can use to convert string local (for instance, 'local 8 = pop weight land' or 'local 7 pop weight land') to string variable.

The code that I have been working on is the following:

Code:
local  1 Index_2018m9(`=tm(2017m1)') Index_2018m9(`=tm(2017m2)')  Index_2018m9(`=tm(2017m3)')  Index_2018m9(`=tm(2017m4)')  ///
         Index_2018m9(`=tm(2017m5)') Index_2018m9(`=tm(2017m6)')  Index_2018m9(`=tm(2017m7)')  Index_2018m9(`=tm(2017m8)')  ///
         Index_2018m9(`=tm(2017m9)') Index_2018m9(`=tm(2017m10)') Index_2018m9(`=tm(2017m11)') Index_2018m9(`=tm(2017m12)') ///
         Index_2018m9(`=tm(2018m1)') Index_2018m9(`=tm(2018m2)')  Index_2018m9(`=tm(2018m3)')  Index_2018m9(`=tm(2018m4)')  ///
         Index_2018m9(`=tm(2018m5)') Index_2018m9(`=tm(2018m6)')  Index_2018m9(`=tm(2018m7)')  Index_2018m9(`=tm(2018m8)')  ///
                                     Index_2018m9(`=tm(2018m10)') Index_2018m9(`=tm(2018m11)') Index_2018m9(`=tm(2018m12)')

local  2 Index_2018m9(`=tm(2017m5)') Index_2018m9(`=tm(2017m6)')  Index_2018m9(`=tm(2017m7)')  Index_2018m9(`=tm(2017m8)')  ///
         Index_2018m9(`=tm(2017m9)') Index_2018m9(`=tm(2017m10)') Index_2018m9(`=tm(2017m11)') Index_2018m9(`=tm(2017m12)') ///
         Index_2018m9(`=tm(2018m1)') Index_2018m9(`=tm(2018m2)')  Index_2018m9(`=tm(2018m3)')  Index_2018m9(`=tm(2018m4)')  ///
         Index_2018m9(`=tm(2018m5)') Index_2018m9(`=tm(2018m6)')  Index_2018m9(`=tm(2018m7)')  Index_2018m9(`=tm(2018m8)')  ///
                                     Index_2018m9(`=tm(2018m10)') Index_2018m9(`=tm(2018m11)') Index_2018m9(`=tm(2018m12)')

local  3 Index_2018m9(`=tm(2015m1)') Index_2018m9(`=tm(2015m2)')   ///
         Index_2018m9(`=tm(2015m5)') Index_2018m9(`=tm(2015m6)')   ///
         Index_2018m9(`=tm(2015m9)') Index_2018m9(`=tm(2015m10)')  ///
         Index_2018m9(`=tm(2016m1)') Index_2018m9(`=tm(2016m2)')   ///
         Index_2018m9(`=tm(2016m5)') Index_2018m9(`=tm(2016m6)')   ///
         Index_2018m9(`=tm(2016m9)') Index_2018m9(`=tm(2016m10)')  ///
         Index_2018m9(`=tm(2017m1)') Index_2018m9(`=tm(2017m2)')   ///
         Index_2018m9(`=tm(2017m5)') Index_2018m9(`=tm(2017m6)')   ///
         Index_2018m9(`=tm(2017m9)') Index_2018m9(`=tm(2017m10)')  ///
         Index_2018m9(`=tm(2018m1)') Index_2018m9(`=tm(2018m2)')   ///
         Index_2018m9(`=tm(2018m5)') Index_2018m9(`=tm(2018m6)')   ///
                                     Index_2018m9(`=tm(2018m10)')

local  4 Index_2018m9(`=tm(2015m3)')  Index_2018m9(`=tm(2015m4)')  ///
         Index_2018m9(`=tm(2015m7)')  Index_2018m9(`=tm(2015m8)')  ///
         Index_2018m9(`=tm(2015m11)') Index_2018m9(`=tm(2015m12)') ///
         Index_2018m9(`=tm(2016m3)')  Index_2018m9(`=tm(2016m4)')  ///
         Index_2018m9(`=tm(2016m7)')  Index_2018m9(`=tm(2016m8)')  ///
         Index_2018m9(`=tm(2016m11)') Index_2018m9(`=tm(2016m12)') ///
         Index_2018m9(`=tm(2017m3)')  Index_2018m9(`=tm(2017m4)')  ///
         Index_2018m9(`=tm(2017m7)')  Index_2018m9(`=tm(2017m8)')  ///
         Index_2018m9(`=tm(2017m11)') Index_2018m9(`=tm(2017m12)') ///
         Index_2018m9(`=tm(2018m3)')  Index_2018m9(`=tm(2018m4)')  ///
         Index_2018m9(`=tm(2018m7)')  Index_2018m9(`=tm(2018m8)')  ///
         Index_2018m9(`=tm(2018m11)') Index_2018m9(`=tm(2018m12)')

local  5 Index_2018m9(`=tm(2015m1)') Index_2018m9(`=tm(2015m3)')   ///
         Index_2018m9(`=tm(2015m5)') Index_2018m9(`=tm(2015m7)')   ///
         Index_2018m9(`=tm(2015m9)') Index_2018m9(`=tm(2015m11)')  ///
         Index_2018m9(`=tm(2016m1)') Index_2018m9(`=tm(2016m3)')   ///
         Index_2018m9(`=tm(2016m5)') Index_2018m9(`=tm(2016m7)')   ///
         Index_2018m9(`=tm(2016m9)') Index_2018m9(`=tm(2016m11)')  ///
         Index_2018m9(`=tm(2017m1)') Index_2018m9(`=tm(2017m3)')   ///
         Index_2018m9(`=tm(2017m5)') Index_2018m9(`=tm(2017m7)')   ///
         Index_2018m9(`=tm(2017m9)') Index_2018m9(`=tm(2017m11)')  ///
         Index_2018m9(`=tm(2018m1)') Index_2018m9(`=tm(2018m3)')   ///
         Index_2018m9(`=tm(2018m5)') Index_2018m9(`=tm(2018m7)')   ///
                                     Index_2018m9(`=tm(2018m11)')

local  6 Index_2018m9(`=tm(2016m5)') Index_2018m9(`=tm(2016m7)')   ///
         Index_2018m9(`=tm(2016m9)') Index_2018m9(`=tm(2016m11)')  ///
         Index_2018m9(`=tm(2017m1)') Index_2018m9(`=tm(2017m3)')   ///
         Index_2018m9(`=tm(2017m5)') Index_2018m9(`=tm(2017m7)')   ///
         Index_2018m9(`=tm(2017m9)') Index_2018m9(`=tm(2017m11)')  ///
         Index_2018m9(`=tm(2018m1)') Index_2018m9(`=tm(2018m3)')   ///
         Index_2018m9(`=tm(2018m5)') Index_2018m9(`=tm(2018m7)')   ///
                                     Index_2018m9(`=tm(2018m11)')

local  7 Index_2018m9(`=tm(2015m1)') ///
         Index_2018m9(`=tm(2015m5)') ///
         Index_2018m9(`=tm(2015m9)') ///
         Index_2018m9(`=tm(2016m1)') ///
         Index_2018m9(`=tm(2016m5)') ///
         Index_2018m9(`=tm(2016m9)') ///
         Index_2018m9(`=tm(2017m1)') ///
         Index_2018m9(`=tm(2017m5)') ///
         Index_2018m9(`=tm(2017m9)') ///
         Index_2018m9(`=tm(2018m1)') ///
         Index_2018m9(`=tm(2018m5)')

local  8 Index_2018m9(`=tm(2015m2)')  Index_2018m9(`=tm(2015m4)')  ///
         Index_2018m9(`=tm(2015m6)')  Index_2018m9(`=tm(2015m8)')  ///
         Index_2018m9(`=tm(2015m10)') Index_2018m9(`=tm(2015m12)') ///
         Index_2018m9(`=tm(2016m2)')  Index_2018m9(`=tm(2016m4)')  ///
         Index_2018m9(`=tm(2016m6)')  Index_2018m9(`=tm(2016m8)')  ///
         Index_2018m9(`=tm(2016m10)') Index_2018m9(`=tm(2016m12)') ///
         Index_2018m9(`=tm(2017m2)')  Index_2018m9(`=tm(2017m4)')  ///
         Index_2018m9(`=tm(2017m6)')  Index_2018m9(`=tm(2017m8)')  ///
         Index_2018m9(`=tm(2017m10)') Index_2018m9(`=tm(2017m12)') ///
         Index_2018m9(`=tm(2018m2)')  Index_2018m9(`=tm(2018m4)')  ///
         Index_2018m9(`=tm(2018m6)')  Index_2018m9(`=tm(2018m8)')  ///
         Index_2018m9(`=tm(2018m10)') Index_2018m9(`=tm(2018m12)')

local  9 Index_2018m9(`=tm(2016m2)')  Index_2018m9(`=tm(2016m4)')  ///
         Index_2018m9(`=tm(2016m6)')  Index_2018m9(`=tm(2016m8)')  ///
         Index_2018m9(`=tm(2016m10)') Index_2018m9(`=tm(2016m12)') ///
         Index_2018m9(`=tm(2017m2)')  Index_2018m9(`=tm(2017m4)')  ///
         Index_2018m9(`=tm(2017m6)')  Index_2018m9(`=tm(2017m8)')  ///
         Index_2018m9(`=tm(2017m10)') Index_2018m9(`=tm(2017m12)') ///
         Index_2018m9(`=tm(2018m2)')  Index_2018m9(`=tm(2018m4)')  ///
         Index_2018m9(`=tm(2018m6)')  Index_2018m9(`=tm(2018m8)')  ///
         Index_2018m9(`=tm(2018m10)') Index_2018m9(`=tm(2018m12)')

local 10 Index_2018m9(`=tm(2015m2)')   ///
         Index_2018m9(`=tm(2015m6)')   ///
         Index_2018m9(`=tm(2015m10)')  ///
         Index_2018m9(`=tm(2016m2)')   ///
         Index_2018m9(`=tm(2016m6)')   ///
         Index_2018m9(`=tm(2016m10)')  ///
         Index_2018m9(`=tm(2017m2)')   ///
         Index_2018m9(`=tm(2017m6)')   ///
         Index_2018m9(`=tm(2017m10)')  ///
         Index_2018m9(`=tm(2018m2)')   ///
         Index_2018m9(`=tm(2018m6)')   ///
         Index_2018m9(`=tm(2018m10)') 

local predictores 1 2 3 4 5 6 7 8 9 10
Those "locals", I use them as independent variables in a regression. I made many regressions. From those regressions, I chose the best regression and therefore I know what "local" number (for instance, "local 8") was used for that regression (for example, DID regression).
Now, I want to run another regression (for example, data panel) with the independent variables that were used for the best DID regression.
I do not know how to use the same "local" (for instance, "local 8") I used in a loop, but now for another regression.

It occurs to me to convert the "local" to a variable string and when I want to use the "local 8" (now in a variable string), I will convert the variable string to "local" one. But I do not know how.

I hope I didn't confuse you.

Thanks a lot for your help

Alexis Rodas