How to execute multiple-line selection in do-file editor of Stata?
Does anyone know how to use the "execute selection" function in the do-file editor of Stata for code that spans multiple lines? Currently I can'开发者_C百科t find a way to do this without using the #delimit ; system which requires repeating "delimit ;" at the beginning of every block I want to run. Any suggestions appreciated!
I believe that you might be understanding the #delimit ;
command wrongly: this is useful when you are coding a do-file to execute it in its entirety afterwards. I also assume that you are using Stata 11, since previous versions behave differently (if I recall well, Stata 10 SE for Mac does not support //
comments and delimiting, for example).
If you are executing only a fraction of the code, use ///
at the end of a line to continue its command on the next one.
Basic example (that will clear any open data, so beware):
sysuse lifeexp, clear
sc lexp safewater, ///
mlab(country);
This should run flawlessly even if you execute the sysuse
command and the sc
(scatter
) commands separately. The sc
command has the mlab
option (to add labels to the data points) on a different line, but both lines will be interpreted as only one command due to the ///
indication.
Hope this helps!
精彩评论