Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Matrix colnames? Very basic question.
From
Sergiy Radyakin <[email protected]>
To
[email protected]
Subject
st: Matrix colnames? Very basic question.
Date
Thu, 5 Aug 2010 16:16:58 -0400
Dear All,
perhaps I am missing someting very basic. In the code attached below there is a
conformability error upon assigning the colnames for matrix b because
matrix colnames A=`:colnames A'
does not work for any matrix (only those that have no spaces in their
colnames), which
is at the very least strange. More specifically it is the problem of
the extended macro
colnames, which does not enclose individual colnames into quotes. The command
matrix colnames on itself works fine.
I was hoping to be able to extract the colnames individually for a
given matrix, but don't
see it possible as the `:colnames M' seems to be the only way to get
the matrix colnames
in Stata. My current solution (CopyMatrixNames program not listed)
involves Mata, which
I think is a bit of a heavy weight for this task.
QUESTION: how to copy the column names of one matrix to another
(conforming) matrix in
case they may contain spaces without Mata?
Thank you, Sergiy Radyakin
PS: is the above problem a bug/feature/known limitation/smth else?
--------- --------- ---------
--------- --------- ---------
capture matrix drop a b
matrix a=1,2,3\4,5,6
matrix coleq a="a 1" "a 2" b
matrix colnames a = "alpha beta" "gamma delta" omega
matrix roweq a = "first eq" "second eq"
matrix rownames a = "first element" "second element"
matrix b=1,2,3\4,5,6
capture noisily matrix colnames b = `:colnames a'
// ^^^ direct assignment above causes a conformability error
matrix list b
CopyMatrixNames, source(a) destination(b)
matrix list b
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/