Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Sergiy Radyakin <serjradyakin@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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/

**Follow-Ups**:**st: Snapping Windows together in Stata 11 for Macs***From:*Paul Connolly <paul.connolly@qub.ac.uk>

- Prev by Date:
**st: RE: AW: RE: RE: Estout for metan?** - Next by Date:
**st: Snapping Windows together in Stata 11 for Macs** - Previous by thread:
**[no subject]** - Next by thread:
**st: Snapping Windows together in Stata 11 for Macs** - Index(es):