Agriculture Reference
In-Depth Information
Stata uses the convention of adding .do or .ado as extensions to pro-
gram files. These files are actually just text files that Stata interprets as
executable programming code. The .do extension refers to a do-file as it
is called because it does something. These files must first be loaded into
computer memory before they can be used by the user. It differs from
an ado file in that an ado file is loaded into memory and executed in
one step. That is, a command that is implemented as an ado file when
typed into the Command window in the correct format will automati-
cally load and run. This makes the ado files seamless to the user, act-
ing as if they are part of the Stata program. If the do-file has been
saved it also can be invoked by using the do command followed by the
file name. Stata will then look in specific directories and the working
directory for the file and execute the commands in the so-named do-
file. If it cannot find the file, it will return a file not found error.
One of the easiest uses of the programming capabilities of Stata
is to use the Do-File Editor to handle a series of commands. A
number of different commands can be executed at one time in a
single file. This can be particularly helpful when similar analysis is
done on several different variables. To demonstrate how this works,
load the data file Large Onion Dataset 2001-02.dta. This dataset
includes several variables from an onion variety trial. These vari-
ables include various yield components (e.g., yield, drywts, jumbo,
and mediums), as well as onion quality parameters (e.g., pungency,
sugar, and doubles). As a starting point to analyzing these data, you
might want to look at an analysis of variance and the means for all
of these variables. This could be done by entering the anova and
tabstat commands in the Command window one after the other
or select the commands from the menus for all the variables. This
might become tedious and can be accomplished more quickly in the
Do-File Editor. Open a new do-file window by selecting from the
Do-File Editor under the Windows menu. Then enter the follow-
ing commands:
anova yield variety rep
tabstat yield, by( variety )
These commands then can be copied and pasted into the same win-
dow. You will want to paste these commands in the window six times.
Search WWH ::




Custom Search