I'm new to writing programs (functions) in stata, so I'm looking for both a specific answer to this question, and a generic answer for locations/terms to search for on related topics.
My specific question is this:
I'm writing programs to make minor variations on complex plots. I'd like to be able to set up the general plot in a program and pass options through to the tw graphics plotter, rather than having to hard code all the options.
here is a minimal working example:
This strategy _works_ to pass the nodraw option through to tw, but its inelegant, and I'm sure that there is some general way to just send all of the default plotting options into a program. How do I do this more elegantly than my current solution?
A more general question:
I'm aware of the formal stata documentation, but I'm having a hard time making progress in googling questions about writing stata programs, because the terms are so general (stata, program, options doesn't get me very far). I've read the manual https://www.stata.com/manuals13/u18.pdf carefully, and occasionally find useful posts here or on stack exchange (thanks Nick Cox!), but are there other places I can look to address ongoing questions about how to write programs or find example code about programming stata?
Thank you!
My specific question is this:
I'm writing programs to make minor variations on complex plots. I'd like to be able to set up the general plot in a program and pass options through to the tw graphics plotter, rather than having to hard code all the options.
here is a minimal working example:
Code:
capture program drop toy_syntax
program define toy_syntax
syntax varlist(max =2) [if], ms(string) [nodraw(string)]
tw (scatter `1' `2') `if', title("`ms'") `nodraw'
end
toy_syntax var1 var2 if var3 < 100, ms("mwe") nodraw("nodraw")
This strategy _works_ to pass the nodraw option through to tw, but its inelegant, and I'm sure that there is some general way to just send all of the default plotting options into a program. How do I do this more elegantly than my current solution?
A more general question:
I'm aware of the formal stata documentation, but I'm having a hard time making progress in googling questions about writing stata programs, because the terms are so general (stata, program, options doesn't get me very far). I've read the manual https://www.stata.com/manuals13/u18.pdf carefully, and occasionally find useful posts here or on stack exchange (thanks Nick Cox!), but are there other places I can look to address ongoing questions about how to write programs or find example code about programming stata?
Thank you!
Comment