Agriculture Reference
In-Depth Information
be confusing to Microsoft Office® ® users where macros are programs
implemented within Microsoft Office. Microsoft has its Visual Basic
for Applications (VBA), which is an implementation of Visual Basic
that is used within the Microsoft Office environment where these
programs are called macros.
Stata programs can actually be entered interactively, but rarely are.
Here is an example:
. program quote
1. display “Now is the time for all good men to come
to the aid of their country.”
2. end
Once this program (quote) has been defined, all you have to do is
type the word quote and the program executes displaying the quota-
tion. Usually programs are entered in a do-file so that the program can
be used over and over again. In addition, as programs become more
complex, you will need to make corrections or debug them before they
run correctly. Once a program has been defined in Stata's memory
it cannot be redefined. Thus, if you entered program quote after
having defined it by our example above, Stata will return an error
message that the program is already defined. To prevent this from
happening, the first line in the do-file should be
capture program drop quote
he capture command executes any subsequent command and
suppresses any error codes. he drop command drops the quote pro-
gram before redefining it. If the program was not in memory and we
just had the drop command, it would return an error code, so that's
why capture is included.
Before beginning a program, let's take a closer look at the Do-File
Editor and how Stata handles such files. This editor window can be
opened either from the Main window by selecting the icon that looks
like a notepad and pencil or from the Windows' menu. Saved do-files
can be opened from the File menu or selecting the Folder icon in the
Main window.
The Do-File Editor has several icons across the top of the window,
which will be somewhat different depending on the operating system
Search WWH ::




Custom Search