Reputation: 79
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?
Upvotes: 0
Views: 403
Reputation: 444
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.
Upvotes: 2
Reputation: 1037
You can make a form that you can use from Stata's drop-down menu. See the help dialog_programming
page.
Upvotes: 0
Reputation: 1555
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.
Upvotes: 1