Skip to content

stata

This directory provides Talon voice command and syntax support for the Stata statistical programming language. By combining configuration mappings, custom action implementations, and a list of common Stata commands, it allows developers to write Stata code and run statistical commands entirely by voice.

How Stata Support Works

The support is built using three cooperating files:

  • stata.talon acts as the entry point, defining the syntax voice commands and activating universal coding tags when a .stata file is open.
  • stata.py acts as the backend handler. It configures the abstract syntax tags (like operators and functions) into actual Stata-specific syntax and implements the mechanics of inserting library imports and program blocks.
  • code_common_function.talon-list registers a dictionary of frequently used Stata operations and package wrappers to make them easily dictatable.

Key Components

stata.talon

This file targets active files with the stata language code. It performs the following setup:

  • Syntax Tagging: Enables standardized coding behaviors such as imperative programming structures (user.code_imperative), comment blocks, standard operators, functions, and library management.
  • Settings: Instructs the formatter to output private functions in SNAKE_CASE (consistent with typical Stata program naming conventions).
  • Custom Snippets and Commands:
    • Maps the word arg to insert standard statistical options like standard error cluster parameters.
    • Maps state for val to quickly spit out a Stata for loop template.
    • Provides quick phrases to install packages via SSC (e.g., s s c install estout via s s c install <user.code_libraries>).

stata.py

This Python module defines the context matches for Stata files and overrides the default coding actions to produce Stata-specific text:

  • Operator Mapping: Defines symbols and formatting for common mathematical and assignment operations. For example, the modulo operator % is mapped to the functional mod(x, y) syntax, and standard logical and arithmetic operators (==, !=, &, |) are defined.
  • Parameters & Libraries: Registers lists of parameters—such as variance-covariance estimators (vce(cluster) and vce(robust))—and popular external libraries like estout.
  • Program & Function Structuring: Overrides standard function-creation actions. Creating a private function by voice translates into a Stata program ... end block, positioning the cursor correctly inside the body of the program.

code_common_function.talon-list

This list contains short, recognizable spoken names mapped to their corresponding Stata commands. It includes:

  • Core commands: global, local, and regress / reg.
  • Package-specific helpers: Contains support for the widely used estout suite (estadd, estout, estpost, eststo, esttab), which is the standard toolset for formatting and exporting regression tables in Stata.