Why user-written Programs
The following list of Stata programs can be utilized in finance and accounting research and other related fields. In finance, we often work with large datasets, and some of the built-in data tools in Stata can be quite slow when processing such data sets. For example, the xtile command used for creating quantile groups, or the rolling command for rolling window calculations, can be particularly slow. These limitations have been a source of frustration for me and have motivated me to develop the following commands.
1. asm
We have written an easy to use Stata® program, asm.ado for creation and testing of momentum portfolio returns. The program offers a large number of options which have been used in the momentum literature. This program employs well-known momentum portfolio strategies as suggested in Jagadesh and Titman (1993) and many other options suggested in subsequent papers. This program is equally useful for academics and practitioners. The program offers the following features Read more …
2. asdoc
asdoc sends Stata output to MS Word . asdoc creates high-quality, publication-ready tables from various Stata commands such as summarize, correlate, pwcorr, tab1, tab2, tabulate1, tabulate2, tabstat, ttest, regress, table, amean, proportions, means, and many more. Using asdoc is pretty easy. We need to just add asdoc as a prefix to Stata commands. asdoc has several built-in routines for dedicated calculations and making nicely formatted tables. Read more …
3. asrol
asrol calculates descriptive statistics in a user’s defined rolling-window or over a grouping variable. The descriptive statistics include standard deviation, mean, median, geometric mean, products, count, minimum, maximum, number of missing values, first observation, last observation, and total. asrol can efficiently handle all types of data structures such as data declared as time series or panel data, undeclared data, or data with duplicate values, missing values or data having time series gaps. Read more …4. ascol
It is easy to use ascol to convert stock returns or price data from daily to weekly, monthly, quarterly, or yearly frequency. Since returns and prices require different conversion methods—for example, returns must be summed when converting from daily to weekly frequency, while prices are typically represented by the end-of-week value—the program offers options for handling both types of data. It is also robust against various data issues, such as undeclared formats, duplicate entries, missing values, or time series gaps. Read more …
5. asreg
asreg estimates a linear regression model of a dependent variable on one or more independent variables using either a user-defined rolling window or a grouping variable. The estimation of rolling beta or cross-sectional regression is very common in finance. asreg delivers performance that is an order of magnitude faster than conventional approaches—such as Stata loops or Stata’s official rolling command—and its speed is comparable to that of asrol. All calculations, from rolling window computations and parameter estimations to writing results to Stata variables, are executed in the Mata language. Read more …
6. astile
astile is a fast alternative to Stata’s xtile command for generating quantile-based categorical variables. It efficiently assigns observations to quantiles based on a specified variable, improving performance on large datasets. Unlike xtile, astile supports the by(groupvar) option, allowing quantile calculations within groups. For example, we might be interested in making 10 firm size-based portfolios. This will involve placing the smallest 10% firms in portfolio 1, next 10% in portfolio 2, and so on. Read more …7. asgen
asgen generates a new variable by computing the weighted average mean of an existing variable or expression. The weights are derived from another numeric variable specified in the weight(varname) option. The command supports conditional statements using if and in. It also allows grouped calculations with the by(groupvar) option, making it suitable for panel data analysis. Read more …8. astx
astx finds descriptive statistics for a specific variable over a grouping variable. Further, it estimates t-statistics and sends the output file to MS Excel File Read more …
9. astx
searchfor finds text in string variables and either lists the selected variables on screen or edits the variables in Data Editor. The search text is capitalization free. Read more …