Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: Re: st: a little bit of Stata programming....


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: Re: st: a little bit of Stata programming....
Date   Wed, 19 Sep 2007 17:30:50 +0100

First, I assume that that "until" is not to be taken
literally and that all your globals contain lists
of variable names (which don't need expansion).

Then what you want is I think

foreach i of local out {
local x : list xvars - i
reg `i' `x'
}

Note incidentally that, although it was not part
of your question,

foreach i in out

is quite wrong for what you want.

Both this point and the answer to your question are
spelled out in the help, so perhaps you should indicate
to StataCorp what is unclear in their documentation.

Nick
[email protected]


Nirina F

I tried to see but still couldn't figure out.
so you mean there is an option command for me to tell xvars to not include i ?

Austin Nichols

> see -help macrolists- (linked from -help extended_fcn- which is linked
> from -help macro-).

Nirina F

> > I have:
> >
> > global x "x1 until x8"
> > global y "y1 until y15"
> > global z "z1 until z3"
> > global w "w1 until w24"
> > global k "k1 until k9"
> >
> > local xvars "$x $y $z $w $k"
> > local out "x1 y1 z1 w1 k1 x7 y13 z3 k4 w20"
> >
> > I would like to do
> >
> > foreach i in out {
> > reg `i' `xvars'
> > }
> >
> > but now I would have depedent variable collinear with one of control
> > variable. So how could I run the reg but telling my controls `xvars'
> > to not include what is taken by `i' ?

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