How to execute multiple-line selection in do-file editor of Stata?

ⅰ亾dé卋堺 提交于 2019-12-12 15:31:58

问题


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'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!


回答1:


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!



来源:https://stackoverflow.com/questions/5985751/how-to-execute-multiple-line-selection-in-do-file-editor-of-stata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!