I'm trying to append quoted strings that contain spaces to a local macro, which I then pass into the -mlabels- option of -estout-. This code
displays
where for some reason, the quotes on the first quoted string in the loop are omitted. How do I fix this? The actual code is much more complicated, but basically, a local macro named -estim_name- is created at some point, and then at the end of the loop, that local macro is append to the local macro -estim_names-. These are then passed into -estout-:
This is example code only, but I post it as a minimal working example of the larger code base to demonstrate the problem. To be very clear, since the actual code is much more complicated, a solution that just appends some value to -estim_names- directly WILL NOT WORK, e.g. this:
The complete code base loops over numerous different models, and -estim_names- is created by a bunch of branching statements, so I can't condense this all into one line.
Code:
sysuse auto, clear local estim_names foreach v of varlist mpg headroom trunk weight { regress price `v', robust estimates store estim_`v' local estim_name `""robust `v'""' local estim_names `estim_names' `estim_name' } display `"`estim_names'"'
Code:
robust mpg "robust headroom" "robust trunk" "robust weight"
Code:
estout estim_mpg estim_headroom estim_trunk estim_weight /// using "table.txt", style(fixed) replace mlabels(`estim_names')
This is example code only, but I post it as a minimal working example of the larger code base to demonstrate the problem. To be very clear, since the actual code is much more complicated, a solution that just appends some value to -estim_names- directly WILL NOT WORK, e.g. this:
Code:
local estim_names `estim_names' "robust `v'"
Comment