Statalist


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

st: RE: loop and local question with appendmodels


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: loop and local question with appendmodels
Date   Wed, 29 Apr 2009 12:10:52 +0100

A basic kind of solution is 

local t=0
foreach x of local r {
	...
	local elist `elist' e`t' 
	...
	local t = `t' + 1
}

Then use `elist' in your call to -appendmodels-. 

By the way, "local variable" is not correct Stata terminology. See

http://www.stata.com/statalist/archive/2008-08/msg01258.html

Nick 
[email protected] 

moleps islon

I'm trying to create a local variable that creates a new local with
more variables, hard to explain but easier to see the code:



eststo clear
local r "a b c d e f"
local t=0
foreach x of local r {
	stcox "`r'"
	eststo e`t'
	
	
	local t=`t'+1
		
	}
eststo u: appendmodels e0 e1 e2 e3 e4 e5
esttab u



But what I want to do is to create a new local var that can take any
number of variables in r and automatically create a local g that can
be used in the appendmodels command, eg

eststo clear
local r "a b c d e f g h..."
local t=0
foreach x of local r {
	stcox "`r'"
	eststo e`t'
	
	
	local t=`t'+1
	//generate some kind of appended local here (q), that I cannot
figure out//	
	}
eststo u: appendmodels `q'
esttab u

The thing is that appendmodels doesnt allow e0-e8 notation.


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



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