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

st: RE: re: how to quietly svmat?

From   "Nick Cox" <>
To   <>
Subject   st: RE: re: how to quietly svmat?
Date   Tue, 11 Nov 2008 21:11:22 -0000

I agree strongly with Kit's approach here. It's been several years since
I reached for -svmat-. 

However, Kit just plucked a program name out of the air, and
understandably forgot that the name -svmat2- was also used a while back
for a program in this territory which is not yet completely superseded. 

. search svmat2, historical 

gives the details. StataCorp's implication in its .key file coding that
-svmat2- is of historical interest only is not quite correct. Questions
to which "use -svmat2-" is the answer still arise about once per year on

So, I suggest the use of some other name. 


Christopher Baum

Just avoid it entirely and do it in Mata:

mata:mata clear
void function mm_svmat2(string scalar mat, string scalar vlist)
	m = st_matrix(mat)
	vv = tokens(vlist)
	st_view(X=., 1::rows(m), vv)
	X[. , .] = m

program drop _all
prog svmat2
syntax anything [,stub(string)]
local vn = cond("`stub'" == "", "var", "`stub'")
scalar nc = colsof(`anything')
forv i=1/`=nc' {
	local vname "`vn'`i'"
	qui gen double `vname' = .
	local vl "`vl' `vname'"
mata: mm_svmat2("`anything'","`vl'")

webuse auto, clear
qui corr price mpg headroom trunk weight length
mat corr=r(C)

svmat2 corr
svmat2 corr, stub(sergiy)

*   For searches and help try:

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