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

st: RE: tempname


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: tempname
Date   Fri, 4 Oct 2002 12:27:47 -0400

> -----Original Message-----
> From: Jun Xu [mailto:[email protected]] 
> Sent: Friday, October 04, 2002 12:22 PM
> To: [email protected]
> Subject: st: tempname 
> 
> 
> Al Statalisters:
> 
> I have a question related to tempname.  I have a series of 
> matrices obtained 
> through post-estimation, and the number of matrices is 
> determined by the 
> info in the return or est list.  Further, I need to tempname 
> these matrices. 
>   I thought of an awkward way, not sure if there is any 
> command in Stata can 
> take care of that.  To make my question clear, I use a mock 
> example that's 
> similar to mine, but much simpler:
> *******************************************************
> capture program drop what
> program define what
> forval i=1/4 {
> tempname mat`i'
> }
> forval i=1/4 {
> mat `mat`i''=[`i']
> mat list `mat`i''
> 
> }
> end
> 
> what
> *******************************************************
> 
> Is there any options after tempname that can facilitate such needs 
> especially when I have several, not just the mat`i''s.  Many thanks.
> 
> Jun Xu
> Department of Sociology
> Indiana UNiversity at Bloomington

It would be helpful if you said more about what you are trying to do
here.  If you want four matrices that you can refer to in sequence, this
seems like a good approach.  If, say, you want to generate a set of
matrices to pick up the estimation results, maybe something like this is
what you are looking for?

if "`e(cmd)'"=="regress" {
	local mats "b V"
}
else if "`e(cmd)'"=="heckman" {
	local mats "b V ilog"
}
foreach name of local mats {
	tempname mat_`name'
	matrix `mat_`name'' = e(`name')
}

How you create the tempnames probably depends on how you want to use
them...

Nick Winter
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index