Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Naming rows of matrix

From   Herb Smith <[email protected]>
To   [email protected]
Subject   st: Naming rows of matrix
Date   Wed, 20 Jul 2005 19:09:12 -0400 (EDT)

Suppose I want to label the 12th row of a matrix:	1982-83

If I assign this value to a local macro, and then use matname, everything
is fine:

. local tmp12a="1982-83"
. matname matrixname `tmp12a', row(12) e

i.e., when I list the matrix, the label is	1982-83

This is a silly way to do things, but now consider the problem where a
label such as 	1982-83		is the 12th case of a variable such as
var15 .

. local tmp12b=var15[12]

assigns the string	1982-83		to the new local macro, in the
sense that

. dis `tmp12b'

displays	1982-83

but the command

. matname matrixname `tmp12b', row(12) e

results in the label:	var15[12]	being assigned to the 12th row of
the matrix--not the string associated with this element.

Is there a workaround for this?

Or, more generally, is there a simple way to assign the values of a
variable to the corresponding rows of a matrix (which is what I am trying
to do here)?

Thanks in advance,

--Herb Smith

Professor of Sociology and
Director, Population Studies Center
3718 Locust Walk CR
University of Pennsylvania
Philadelphia, PA  19104-6298

[email protected]

215.898.7768 (office)
215.898.2124 (fax)
*   For searches and help try:

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