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

st: RE: Converting variables to a matrix


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Converting variables to a matrix
Date   Fri, 14 May 2004 17:09:15 +0100

This should work if the string values
are acceptable as row names: 

sysuse auto
gen M = word(make,1) 
replace M = subinstr(M, ".","",.) 
mkmat mpg weight, matrix(A) 

forval i = 1/`=_N' { 
	matname A `=M[`i']', row(`i') explicit 
} 

Nick 
n.j.cox@durham.ac.uk 

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Faye Turner

> How do I tell STATA to use the first column (a string variable) of my 
> dataset as the row names when converting variables to a matrix?


*
*   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