[ U ] 18 Programming Stata 39
Technical note
Stata looks in various directories for ado-files, defined by the c-class value c(adopath), which
contains
BASE;SITE;.;PERSONAL;PLUS;OLDPLACE
The words in capital letters are codenames for directories, and the mapping from codenames to
directories can be obtained by typing the sysdir command. Here is what sysdir shows on one
particular Windows computer:
. sysdir
STATA: C:\Program Files\Stata13\
BASE: C:\Program Files\Stata13\ado\base\
SITE: C:\Program Files\Stata13\ado\site\
PLUS: C:\ado\plus\
PERSONAL: C:\ado\personal\
OLDPLACE: C:\ado\
Even if you use Windows, your mapping might be different because it all depends on where you
installed Stata. That is the point of the codenames. They make it possible to refer to directories
according to their logical purposes rather than their physical location.
The c-class value c(adopath) is the search path, so in looking for an ado-file, Stata first looks
in BASE then in SITE, and so on, until it finds the file. Actually, Stata not only looks in BASE
but also takes the first letter of the ado-file it is looking for and looks in the lettered subdirectory.
For files with the extension .style, Stata will look in a subdirectory named style rather than
a lettered subdirectory. Say that Stata was looking for gobbledygook.ado. Stata would look up
BASE (C:\Program Files\Stata13\ado\base in our example) and, if the file were not found
there, it would look in the g subdirectory of BASE (C:\Program Files\Stata13\ado\base\g)
before looking in SITE, whereupon it would follow the same rules. If Stata were looking for
gobbledygook.style, Stata would look up BASE (C:\Program Files\Stata13\ado\base in our
example) and, if the file were not found there, it would look in the style subdirectory of BASE
(C:\Program Files\Stata13\ado\base\style) before looking in SITE, whereupon it would
follow the same rules.
Why the extra complication? We distribute hundreds of ado-files, help files, and other file types
with Stata, and some operating systems have difficulty dealing with so many files in the same directory.
All operating systems experience at least a performance degradation. To prevent this, the ado-directory
we ship is split 28 ways (letters a– z, underscore, and style). Thus the Stata command ci, which
is implemented as an ado-file, can be found in the subdirectory c of BASE.
If you write ado-files, you can structure your personal ado-directory this way, too, but there is no
reason to do so until you have more than, say, 250 files in one directory.
Technical note
After finding and running gobbledygook.ado, Stata calculates the total size of all programs that it
has automatically loaded. If this exceeds adosize (see [P] sysdir), Stata begins discarding the oldest
automatically loaded programs until the total is less than adosize. Oldest here is measured by the
time last used, not the time loaded. This discarding saves memory and does not affect you, because
any program that was automatically loaded could be automatically loaded again if needed.
It does, however, affect performance. Loading the program takes time, and you will again have to
wait if you use one of the previously loaded-and-discarded programs. Increasing adosize reduces
this possibility, but at the cost of memory. The set adosize command allows you to change this