Hello,
I wrote the following code that saves variables' labels into a local, and then creates plots of the sum of two coefficients from a quantile regression using coefplot in Stata 14.1MP.
The idea is that for each graph (created with coefplot) I get the variable label to be included in the title of the plot (e.g. `"Mg. Effect of `l`var'' for EMs On Conditional Quantile Q{sub:{&tau}}"' ).
However, when I produce the plots, the label part is left blank (as if not specified or as if label was non-existent). I get something like "Mg. Effect of for EMs On Conditional Quantile Q{sub:{&tau}}" What am I not seeing?
I am posting my original code, but if need be, I could also post a replicable example. Also please see attached a picture (png) of the plot created.
Thank you.

I wrote the following code that saves variables' labels into a local, and then creates plots of the sum of two coefficients from a quantile regression using coefplot in Stata 14.1MP.
The idea is that for each graph (created with coefplot) I get the variable label to be included in the title of the plot (e.g. `"Mg. Effect of `l`var'' for EMs On Conditional Quantile Q{sub:{&tau}}"' ).
However, when I produce the plots, the label part is left blank (as if not specified or as if label was non-existent). I get something like "Mg. Effect of for EMs On Conditional Quantile Q{sub:{&tau}}" What am I not seeing?
I am posting my original code, but if need be, I could also post a replicable example. Also please see attached a picture (png) of the plot created.
Thank you.
Code:
global assets1 "L_fin_a L_fin_a_debt L_liquid L_a2 L_assets" set more off estimates clear label var L_fin_a "Total assets" /* label vars for graph */ label var L_fin_a_debt "Assets (debt)" label var L_liquid "Assets (liquid)" label var L_a2 "Assets (highly liquid)" label var L_assets "Assets(WEO)" *** This code: for each asset: Produces the gamma+beta coef and plots w std. errors. foreach var of global assets1 { local quantiles 1 5 10 25 50 75 90 95 // K quantiles that you care about local models "" // names of K quantile models for coefplot to graph local xlabel "" // for x-axis labels local j=1 // counter for quantiles foreach q of numlist `quantiles' { qreg risk D_EM L_cab_mean L_growth L_default L_reserves vix L_inflation L_gross_debt `var' `var'_EM ,quantile(`q') nlcom (me_tu:_b[`var']+_b[`var'_EM]), post estimates store me_tu`q' local models `"`models' me_tu`q' || "' local xlabel `"`xlabel' `j++' "Q{sub:`q'}""' } di "`models' di `"`xlabel'"' di "`l`var''" *Keep labels for graphs foreach var of var * { local l`var' : variable label `var' if `"`l`var''"' == "" { local l`var' "`var'" } } coefplot `models' /// , vertical bycoefs /// xlab(none) xlabel(`xlabel', add) /// title(`"Mg. Effect of `l`var'' for EMs On Conditional Quantile Q{sub:{&tau}}"', size(medsmall)) /// ytitle("Bond Spread Basis Points" "") yline(0) ciopts(recast(rcap)) graph save `v'_gamma_beta, replace graph export `v'_gamma_beta.png, replace }
Comment