Home  /  Products  /  Programming features

This page contains only historical information and is not about the current release of Stata. Please see our Stata 18 page for information on the current version of Stata.

ORDER STATA
ORDER STATA

Programming features

  • Mata can by used to code ado-file subroutines; see [M-1] ado.

  • New command viewsource displays official and user-written source code. viewsource searches for the specified file along the ado-path and displays the file in the Viewer. This works not only for ado programs, but also for Mata functions that are programmed themselves in Mata. See [P] viewsource.

  • Programmers of estimation commands or commands that work with estimation results can tie postestimation analysis facilities into estat, making their postestimation facilities behave just like those shipped with Stata; see [P] estat programming.

  • New command matlist provides extensive format control for displaying a matrix; see [P] matlist.

  • Macro-extended functions that work on matrices will now work on the matrices stored in r() and e(), including e(b) and e(V). These extended functions include rownames, colnames, roweq, coleq, rowfullnames, and colfullnames. See [P] matrix.

  • c() (c-class returned values) has the following new items:
    item description
    c(Wdays) "Sun Mon ... Sat"
    c(Weekdays) "Sunday Monday Tuesday ... Saturday"
    c(alpha) "a b c d e f g h i j ... x y z"
    c(ALPHA) "A B C D E F G H I J ... X Y Z"
    c(Mons) "Jan Feb ... Dec"
    c(Months) "January February March ... December"
    c(tracehilite) pattern to be highlighted in trace log
    c(maxiter) maximum iterations for maximum likelihood estimators
    c(varabbrev) whether variable abbreviation is on
  • A program can now be assigned properties when the program is declared, and those properties can be checked using macro-extended functions. Specifically,

    • program has the new option properties(), which attaches properties to programs; see [P] program.

    • A new properties macro-extended function allows programmers to obtain the list of properties attached to a program; see [P] macro.


    To learn more, see [P] program properties.

  • Estimation results can now be assigned properties using new option properties() of ereturn post and ereturn repost. These property settings can be checked with the new function has_eprop(). See [P] ereturn and [D] functions.

  • ereturn post now allows posting results without a beta vector, e(b), or a covariance matrix, e(V).

  • version has new option born() to prevent the program from running if the date of the Stata executable is earlier than the specified date. version also issues more-descriptive error messages. See [P] version.

  • On Microsoft Windows and Unix platforms, the new command window manage maintitle allows the main title of the Stata window to be reset; see manage maintitle under window programming.

  • New command levelsof displays a sorted list of the distinct values of a variable. This is especially useful for looping over the values of a variable with, say, foreach. See [P] levelsof.

  • Plugins (also known as DLLs or shared objects) written in C can now be incorporated into Stata to create new Stata commands; see [P] plugin.

  • The maximum number of description lines in a stata.toc file has been increased from 10 to 50; see [R] net

  • New undocumented command _coef_table is a programmer’s tool for displaying coefficient tables; see _coef_table.

  • trace has new setting set tracehilite to highlight a specified pattern in the trace output; see [P] trace.

  • The functionality of macval() has been extended to macro-dereferencing of values in a class. For example, `macval(.a.b.c)' causes the class reference .a.b.c to be macro-expanded only once, rather than being recursively re-expanded when the result itself contained a macro reference.

  • Variable abbreviation can now be turned on and off using the new set varabbrev; see [R] set or type help set varabbrev.

  • Command syntax has new specifier syntax anything(everything) that specifies that anything include if, in, and using; see [P] syntax.

  • Command syntax has new option descriptor cilevel that restricts valid arguments to a standard confidence level and issues appropriate error messages for invalid entries; see [P] syntax.

  • A number of new directives and extensions to existing directives have been added to SMCL. They are summarized below within broad categories; see help smcl for complete documentation.


    • Jumping to marked locations in help or other files

    • Opening help or other files in new or multiple Viewers

    • Special formatting of links to help files

    • Two-column tables with indented wrapping of last column

    • New documentation conventions for syntax-diagram-option tables

    • New documentation conventions for variables and varlists

    • Other new documentation conventions

    • Directives that simplify documenting options

    • Directives abbreviating standard paragraph forms

    • Other new directives and extensions to existing directives

    To learn the new directives, see [P] smcl.

  • Existing command window manage has the following changes and additions:

    • window manage close graph [graphname | _all] closes the Graph window named graphname, if it exists. If _all is specified, it closes all Graph windows.

    • window manage forward graph [graphname] now brings the Graph window named graphname to the top of other windows and otherwise works as before.

    • window manage close viewer [viewername | _all] closes the viewer window named viewername. If _all is specified, it closes all viewer windows.

    • window manage forward viewer [viewername] now brings the viewer window named viewername to the top of other windows and continues to work as before when no viewername is specified.

    • window manage minimize minimizes the main Stata window.

    • window manage restore restores the main Stata window, if it is minimized.

  • Existing command window menu now has new subcommand append_recentfiles to add .dta or .gph files to the Open Recent menu.

  • Existing command confirm variable has new option exact that disallows variable abbreviations.

  • New command svymarkout resets the value of a supplied 0/1 variable to 0 when any of the survey-characteristic variables set by svyset contain missing values; see [SVY] svymarkout.

  • Help files now allow include files. Syntax is INCLUDE help helptopic to include file helptopic .ihlp.

  • String scalars are now supported, meaning that a scalar can contain either a numeric or string value. The maximum length of a string scalar is the same as the maximum length of a string—256 characters in Small Stata and 512 characters in Intercooled Stata or Stata/SE. See [P] scalar.

  • In addition to coding "local x : all scalars" to obtain a list of all defined scalars, you can now code "local x : all numeric scalars" and "local x : all string scalars" to obtain the list restricted to numeric or string scalars. See [P] macro.

  • In macro expansion, double backslash (\\) used to become single backslash (\). Now (but under version control) it becomes single backslash only if the second backslash precedes macro-expansion punctuation (` or $).