*! version 0.32 2024-12-17

Title

matslct -- Subselecting from Stata matrices using mata notation

Syntax

matslct
matrix_expression
[,
options]

matslct
matrix_expression[rowselect;columnselect]
[,
options]

Optional
name(string) If specified, the returned matrix is saved in
a matrix with that name

rowselect(string) Specify row numbers and their order.

columnselect(string) Specify column numbers and their order.

transpose Transpose the subselection matrix.

Matprint options
style(string) Style for output. One of the values smcl (default),
csv (semicolon separated style),
latex or tex (latex style),
html (html style) and
md (markdown style, experimental)

decimals(string) Matrix of integers specifying numbers of
decimals at cell level. If the matrix is smaller than the data matrix the right
most column is copied to get the same number of columns.
And likewise for the bottom row

title(string) Title/caption for the matrix output

top(string) String containing text prior to table content.
Default is dependent of the value of the style option

undertop(string) String containing text between header and table
content.
Default is dependent of the value of the style option

bottom(string) String containing text after to table content.
Default is dependent of the value of the style option

replace Delete an existing using file before adding table

noeqstrip Do not remove duplicate successive roweq or coleq values

nozero Do not show zeros in output

version 13 and up
toxl(string) A string containing up to 5 values separated
by a comma. The values are:

* path and filename on the excel book to save in. Excel book suffix is set/reset to xls for Stata 13 and to xlsx for Stata 14 and above

* the sheet name to save output in

* (Optional) replace - replace/overwrite the content in the sheet

* (Optional) row, column numbers for the upper right corner of the table in the sheet

* (Optional) columnn widths in parentheses. If more columns than widths the last column width is used for the rest

todocx(string) A string containing one or two values separated
by a comma. The values are:

* path and filename on the excel book to save in.

* (Optional) replace - replace/overwrite the content in the sheet

Description

The matslct select a sub matrix from a matrix expression using
the Mata row and column notation for selection and ordering.
The only difference is that selected rows and selected columns are separated by
semicolon (;) instead of a comma(,).

It is tested in Stata 12.1.

Examples

Subselect estimates, confidence intevals and p-value for variables
headroom and length after regression using rowselect and columnselect.

`"sysuse auto ,clear"'

`"regress price displacement gear_ratio headroom length mpg"'

`"matslct r(table), columnselect(3..4) rowselect(1,5,6,4) transpose"'

Subselect estimates, confidence intevals and p-value for variables
headroom and length after regression using using the
[rowselect;columnselect] notation.

`"sysuse auto ,clear"'

`"regress price displacement gear_ratio headroom length mpg"'

`"matslct r(table)[1,5,6,4; 3..4], transpose"'

Stored results

Matrices

r(matslct) The subselection of the matrix.

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com