Hello Statalist,
I'm new to macro manipulation in Stata and I have the following implementation questions with macro list manipulation.
For illustration purpose, suppose I have a local macro called numbers, whose content is "1 2 3 4 5". In real world, it could be much longer, and could be a macro that saves the results from levelsof command in Stata.
1. Is there a command in Stata that allows me to apply prefix to the macro contents? Suppose I have another macro called letters, which contains "a b c d e". How do I construct a new macro that contains "a1 b2 c3 d4 e5" (or in the simpler case "a1 a2 a3 a4 a5")?
2. If I want to convert the macro to a vector (matrix), is there a command that does this, as opposed to looping over the content of numbers?
Would greatly appreciate any help!
Jun
I'm new to macro manipulation in Stata and I have the following implementation questions with macro list manipulation.
For illustration purpose, suppose I have a local macro called numbers, whose content is "1 2 3 4 5". In real world, it could be much longer, and could be a macro that saves the results from levelsof command in Stata.
1. Is there a command in Stata that allows me to apply prefix to the macro contents? Suppose I have another macro called letters, which contains "a b c d e". How do I construct a new macro that contains "a1 b2 c3 d4 e5" (or in the simpler case "a1 a2 a3 a4 a5")?
2. If I want to convert the macro to a vector (matrix), is there a command that does this, as opposed to looping over the content of numbers?
Would greatly appreciate any help!
Jun
Comment