Hi everyone,

I am trying to write a program to generate coefficient plots from regressions, using -coefplot- from SSC in Stata 16. I have regression estimates stored (from SSC's -estout-) as a combination of 3 elements: filter (for eg: totalvol), transformation (IHS or Lograithm) and fixed effect type. So an example of an estimate name is rtotalvol_ihs_tmfe. My program looks like the following:

Code:
cap program drop genplot
program define genplot

    args filter trans fe

    coefplot (r`filter'`trans'_`fe'_*, label(Interaction) ciopts(lcolor(navy*.4 navy*1))  mcolor(black) offset(0.05))  ///
    (l`filter'`trans'_`fe'_*, label(Lincom)  ciopts(lcolor(orange*.4 orange*1)) mcolor(red) offset(-0.4))  ///
    , order(r`filter'`trans'_`fe'_15min l`filter'`trans'_`fe'_15min r`filter'`trans'_`fe'_30min l`filter'`trans'_`fe'_30min ///
    r`filter'`trans'_`fe'_45min l`filter'`trans'_`fe'_45min r`filter'`trans'_`fe'_1hr l`filter'`trans'_`fe'_1hr) ///
    headings(r`filter'`trans'_`fe'_15min = "{bf: 15 min}" r`filter'`trans'_`fe'_30min = "{bf: 30 min}" ///
    r`filter'`trans'_`fe'_45min = "{bf: 45 min}" r`filter'`trans'_`fe'_1hr = "{bf: 1 hr}", labsize(vsmall))  ///
    asequation swapnames name(`filter'`trans'_`fe', replace) `options'
                
end
However I get an invalid syntax error saying "Invalid _30min", which seems to stem from the headings option. The above code works fine if I don't use the program and replace with the values of the arguments. Setting trace on, I think the issue is that r`filter'`trans'_`fe'_15min is not interpreted as one coefficient, and Stata seems to be parsing each argument as a separate coefficient, however I'm not certain. Is there something wrong with the way I'm using arguments in the program?

Thanks very much.