front end in Stata

谁说我不能喝 提交于 2019-12-23 06:07:43

问题


My client has a couple of Stata programs (.do files) that they have been running for a while.

Is it possible to have a front end page or a form for Stata so that we can choose different options/criteria and based on the selections certain programs on Stata are run?

Basically is there a way of creating a form for Stata programs?


回答1:


Stata can be launched in batch mode as

stata /b do whatever.do

So you can form that whatever.do file using the tools that are convenient for you, and then run it as needed. Of course you need to make sure that whatever output is being produced by the client's do-files is being saved in a computer readable format (rather than just left there in the screen for the analyst to copy and paste into Word).

This is implemented by ADePT team of the World Bank, see http://www.worldbank.org/adept. It has a C# GUI, but it runs Stata deep inside.




回答2:


One rough way of making a "form" for a program is to use macros. This is not an explicit dialog form, with textboxes, but it allows you to control a program from a single .do file. Basically, use a bunch of global macros in a separate do file, then have the macros peppered throughout the .do files. My example below does this

Macros File (Form do-file)

global projectname stackoverflow
global exportfmt putdocx
global analysisfolder "/file/path"
global dofilesfolder "/file/path"

The macro projectname allows you to name the project, and thus I put it in all the file save commands, or I save a cleaned dataset using that name. You can even put it inside a file path.

The macro exportfmt you typically use when generating reports using the putdocx or putpdf command. Having a global variable allows me to switch between exporting a pdf or docx.

The macros analysisfolder and dofilesfolder you then use to create file paths that you can call for different projects, just by filling out the "form".

Do-files Usage

$exportfmt clear
$analysisfolder
use $project, clear

$exportfmt begin
$exportfmt paragraph

Thus, create a separate do-file (form do-file) with all your macros, and then you can change them all in one place as you see fit. It's not a true form, but it can simplify changing of many things throughout a Stata program.




回答3:


You can make a form that you can use from Stata's drop-down menu. See the help dialog_programming page.



来源:https://stackoverflow.com/questions/12368972/front-end-in-stata

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