Statalist


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

Re: st: RE: loop and local question with appendmodels


From   moleps islon <moleps2@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: loop and local question with appendmodels
Date   Wed, 29 Apr 2009 13:21:51 +0200

I'll try to remember the "local-lingo" in the future.

Regards


On Wed, Apr 29, 2009 at 1:10 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> 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
> n.j.cox@durham.ac.uk
>
> 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/
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index