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 <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
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
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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