Hi,
I am trying to create variable names by calling a local macro that contains a string, but the quotes in the macro breaks the code. I know that I am mixing up macros and variables names but is there a work around this? The following is a reproducible piece of code that illustrates my problem:
Thank you for your help.
Best,
​Aaditya
I am trying to create variable names by calling a local macro that contains a string, but the quotes in the macro breaks the code. I know that I am mixing up macros and variables names but is there a work around this? The following is a reproducible piece of code that illustrates my problem:
Code:
webuse auto, clear decode foreign, gen(type) // The following will work: forvalues i = 0/1 { reg price mpg if foreign == `i' gen b`i' = _b[mpg] } // But is there a work around for the following: forvalues i = 0/1 { levelsof type, local(type_name) reg price mpg if foreign == `i' gen `type_name' = _b[mpg] }
Best,
​Aaditya
Comment