Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: how to make a string matrix

From   Kit Baum <>
Subject   st: how to make a string matrix
Date   Tue, 15 May 2007 11:55:07 -0400

sacrificial rutabaga

Along with Bill Gould's solution for using Mata to hold a "string matrix", also note that such a creature can be handled by using a set of locals:

local row1 a b c d e
local row2 f g h i j k l
local row3 m n o p
local row4 q r s t u v
local row5 w x y z

local row 3
local col 2
local element : word `col' of `row`row''
di "S[`row',`col'] is `element'"

Note that unlike standard matrices, such a 'matrix' can have a different number of elements per row.

Some may note the resemblance between this solution and an array of pointers to arrays.

Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

* For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index