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

From |
n j cox <n.j.cox@durham.ac.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re st: simple reg |

Date |
Thu, 04 Oct 2007 19:25:21 +0100 |

If I understand you correctly, something like this is closer to what you need. I have used locals throughout, partly a matter of taste. local X "x1 x2 x3 x4 x5 x6 x7" local Y "y1 y2 y3 y4 y5 y6 y7 y8 y9" local Z "z1 z2 z3" local yis "a b c d e f g h i g k" local v "replace" foreach y in `yis' { reg `y' `X' outreg2 using res100407, `v' br e(all) seeout local v "append" reg `y' `X' outreg2 using res100407, `v' br e(all) seeout reg `y' `X' `Y' `Z' outreg2 using res100407, `v' br e(all) seeout } There may be a cuter way to do it, but sometimes what looks like rather repetitive code is just easier to understand, to maintain and to modify. Nirina F With the code below, I would have regressions run one by one like: reg a x1 and then reg a x2 until reg a z3 and then reg b x1 and so on. But what I would like is for it to run : reg a $x, reg a $x $y, reg a $x $y $z and then the same for b etc... Could anyone help on how to program it please. global x "x1 x2 x3 x4 x5 x6 x7" global y "y1 y2 y3 y4 y5 y6 y7 y8 y9" global z "z1 z2 z3" local yis "a b c d e f g h i g k " local xis "$x $y $z" foreach y in `xis'{ foreach x in `yis'{ local v= "replace" local n=1 reg `x' `y' local v="append" local n=`n'+1 outreg2 using res100407, `v' br e(all) seeout } } * * 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/

**Follow-Ups**:**Re: Re st: simple reg***From:*n j cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: How to select missing variables for analysis?** - Next by Date:
**Re: st: RE: How to use Postfile without using a new Stata dataset** - Previous by thread:
**st: simple reg** - Next by thread:
**Re: Re st: simple reg** - Index(es):

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