This page contains only historical information and is not about the current
release of Stata.
Please see our features page
for information on the current version of Stata.
Programming features in Stata 8
Object-oriented programming has been added to Stata. Classes are defined
by the new class command in .class files.
Among other features, classes provide inheritance, encapsulation of data
structures and programs, and program name overloading. Stata's new
graphics and new GUI are implemented via classes.
Stata has a new GUI, which is programmable.
Dialog boxes are created in .dlg files.
Stata has new programmable graphics.
The new serset command is another part of Stata's new
graphics, though its use is not limited to graphics. A serset is a
collection of variables from a dataset that coexists in memory along with
the current dataset, and whose values can be accessed quickly. The new
serset command creates and manipulates sersets.
SMCL has three additions. The new {ccl}
directive outputs the value contained in a constant and current-value
class (c()) object. {center:text} now also
allows {center#:text}, which specifies
that text be centered within a width of # columns. {dialogdialogname:text} launches a dialog box.
The new markin command—for use after
marksample, mark, and markout—creates a macro
containing the smallest inrange that contains the ifexp.
The new c class contains constants, such as the value of pi and current
values of system parameters and settings. Typing creturnlist displays the current settings.
Many macro extended functions have disappeared; that is, they have
disappeared from the documentation, even though they still work. For
instance, to find out whether more was on or off,
there was set more, but it is now gone. c(more) returns the
more setting, and lots more. This is not only more logical, but it is
now easier to find these settings; just type creturn list.
The define in programdefinemyprog is now optional.
New settrace ... features make debugging
programs easier.
settraceexpand specifies whether a line
in a program is to be shown both before and after macro expansion.
settracedepth specifies the level of
nesting to be included in the trace.
settracesep specifies whether a horizontal
separator line that displays the name of the subroutine is displayed in the
trace whenever a subroutine is called or exits.
settraceindent specifies whether the
displayed lines of code are indented according to their nesting
level.
settracenumber specifies whether the
nesting level is displayed at the front of the program lines.
The new comment indicators // and ///
allow new ways of specifying comments and joining lines in do-files and
ado-files.
The postfile command now allows you to post string
variables! postfile now accepts a newvarlist rather than
a varlist, so storage types may be specified, including strings.
The new macro assignment commands local ++lclname
and local --lclname may be used to increment and
decrement lclname.
Macro expansion now allows ++ and --
prefix and suffix operators. `++a' means to
increment a by 1 and substitute the resulting value.
`a++' means substitute the current value of a
and then to increment it by 1. `--a' and
`a--' do the same thing, except that they decrement.
Macro expansion now allows evaluation of expressions, such as
`=2*(`i'+1)', and allows the use of macro extended
functions, such as `: var label `myvar''.
A new macro expansion function
macval(lclname) gives the contents of
lclname as is, without recursive expansion.
Five new macro extended functions have been added, which are mentioned
below. (Another nine new macro extended functions have been added to
support the use of the new serset command mentioned above).
The new macro extended function list allows manipulations
of lists (think lists of variable names, lists of filenames, etc.). For
instance, a|b forms the union of a
and b without repeating in the results the elements that
are in both a and b.
a&b returns the intersection (elements in both
a and b).
The new macro extended function constraint gives
information on constraints.
The new macro extended function permname assists in
naming variables.
The new macro extended function dir obtains file and
directory names.
The new macro extended function length returns the
length in characters of a macro.
The syntax command has two new descriptors:
The new namelist descriptor provides an alternative to
the varlist descriptor. namelist
relaxes the restriction that the names that the user types be variable
names. namelist can be specified in place of
varlist at the front of a command, and
namelist can be specified inside option arguments.
The new anything descriptor makes it easier for
programmers to parse almost-standard syntax, that is, nonstandard
syntax up to if, in, weight, or options, and
standard syntax thereafter.
gettoken has two new options: bind and
qed(lmacname). bind specifies that
expressions within parentheses or brackets be bound together, even when
not parsing on () and []. qed() specifies a local
macroname to be filled in with 1 or 0 according to whether the returned
token was enclosed in quotes in the original string.
assert has a new option null that forces a
return code of 8 on null assertions.
confirm has two new subcommands: confirmmatrix and confirmscalar.
The new findfile command looks for a file along a
specified path and returns the name in r(fn).
The new file command allows programmers to read and write
both ASCII text and binary files.
The new matrixopaccum command forms a new
matrix based on the outer product, within a specified group, of a specified
variable.
The new matrixeigenvalues command
calculates eigenvalues of nonsymmetric matrices.
The new unabcmd command returns a Stata command in
unabbreviated form.
save has a new emptyok option that allows
saving datasets with no variables or observations, and merge and
append have been certified to work with empty datasets. Thus, in
loops that build datasets, you no longer have to treat the first addition
specially. You can create an empty result at the outset and then just
append or merge to the previous result.
describeusing has a new
varlist option that specifies that the saved results
r(varlist) and r(sortlist) be saved along with the other
saved results. r(varlist) will contain the names of the variables
in the dataset, and r(sortlist) will contain the names of the
variables by which the data are sorted. Thus, you no longer have to
use a dataset to find out about it.
You can now obtain the random-number seed at one point in a program and
reset it in another:
. ...
. local seed = "`c(seed)'"
. ...
. set seed `seed'
. ...
The new programming functions maxbyte(),
maxdouble(), maxfloat(),
maxint(), maxlong(),
minbyte(), mindouble(),
minfloat(), minint(), and
minlong() find the largest and smallest number of each
numerical data type. epsdouble() and
epsfloat() give the smallest step size for floating-point
and double-precision numbers. The function byteorder()
gives the byte order for writers of binary files, and
irecode() is another flavor of the
recode() function.
The new programming functions chop() and
clip() return x rounded to an integer and x
within a range.
The new matrix functions are issym(), which determines if a
matrix is symmetric; matuniform(), which makes a matrix filled with
uniformly distributed random numbers; matmissing(), which indicates
if elements of a matrix are missing; hadamard(), which computes the
Hadamard product of two matrices; and vec(), which turns a matrix
into a column vector.
The new string function plural() makes plurals,
proper() obtains the correct capitalization,
word() finds a specific word of a string, and
wordcount() counts the number of words in a string.
The new math functions include tanh(), the hyperbolic
tangent, and its inverse, atanh(); logit()
and invlogit(); and cloglog(), the
complimentary log-log function, and its inverse,
invcloglog(). New functions ceil() and
floor() find the least integer greater than x and the
greatest integer less than x, respectively.
The new probability distribution and density functions include the first
and second derivatives for the gamma distribution,
dgammapda(), dgammapdada(),
dgammapdadx(), dgammapdx(), and
dgammapdxdx(). A variety of density functions have been
added: betaden(), gammaden(),
nbetaden(), tden(),
Fden(), and nFden() for calculating both
central and noncentral distributions. New distribution functions and
inverses are nibeta(), invnibeta(),
nFtail(), and invnFtail().
Existing function
cond(x,a,b,[d]) now has an
optional fourth argument that is returned in case x evaluates to
missing. If the fourth argument is not specified, x=missing
returns b.
Existing function recode(x,x_1,x_2,...,
x_n) now returns missing if the sequence is not weakly
increasing. x_i = . is interpreted as +infinity.
Existing function round(x[.y]) now
allows the argument y, which specifies the unit of rounding, to be
optional.
×
We use cookies
We use cookies to ensure that we give you the best experience on our website—to enhance site navigation, to analyze usage, and to assist in our marketing efforts. By continuing to use our site, you consent to the storing of cookies on your device and agree to delivery of content, including web fonts and JavaScript, from third party web services.
Cookie Settings
Privacy policy
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
Advertising and performance cookies
This website uses cookies to provide you with a better user experience. A cookie is a small piece of data our website stores on a site visitor's hard drive and accesses each time you visit so we can improve your access to our site, better understand how you use our site, and serve you content that may be of interest to you. For instance, we store a cookie when you log in to our shopping cart so that we can maintain your shopping cart should you not complete checkout. These cookies do not directly store your personal information, but they do support the ability to uniquely identify your internet browser and device.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.