I am relatively new to writing ado files in Stata and have come across a problem that I cannot find a solution for.
I would like to have an option in my program that allows any twoway
option to be used (see help twoway_options
) and have run into a problem when using quotes either with just whitespace or within subcommands as demonstrated below.
sysuse gnp96, clear
capture prog drop adding_quotes
prog def adding_quotes
syntax [, tw_opts(string)]
line gnp96 date, `tw_opts'
end
// throws error
adding_quotes, tw_opts(text(7000 97 "Middle Text"))
adding_quotes, tw_opts(xtitle(" "))
// runs
adding_quotes, tw_opts(text(7000 97 `""Middle Text""'))
adding_quotes, tw_opts(xtitle(""))
I would also note that doing away with the syntax
command will also solve the problem, but I would rather keep it in and not have to parse the whole command.
Is it possible to change the syntax
command so that the two commands that throw errors work?
tw_opts(string)
if one usestw_opts(string asis)
the resulting localtw_opts
will take the input as is from the arguments and be able to run any of the above. – Eric HB