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

st: RE: RE: 'Outreg'-ing command after the 'Repeat Stata command'


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: 'Outreg'-ing command after the 'Repeat Stata command'
Date   Thu, 18 Sep 2003 21:44:43 +0100

meganweil

Thanks Nick for your help.  Of course, after trying for
days to figure out a way to do this, I found my answer
almost immediately after posting my question.
You can use multiple commands in the 'repeat stata'
command by separating them with a \.  Then one can
name each of the outreg files based on the outcome variable for
example:

for testa testb: regress X lead\ outreg using "X.doc"
for testa testb: regress X lead age gender\ outreg using "X.doc",
append

If anyone has any other suggestions, let me know.

>>> Indeed. This is what I meant by putting the -outreg-
inside the -for-.

However, to extend an earlier point, unless you
are using Stata 6 or earlier, -for- is going to
bite you if you get too fond of it.

-foreach- is the way to go and to grow.

foreach X in testa testb {
	regress `v' lead age gender
	outreg using "`X'.doc", append
}

There is stuff to learn, but long term this
is a much better construct. There is more
on why in Stata Journal 2(2), 202-222 (2002).
Much the same story is accessible at

http://www.stata.com/support/meeting/8uk/fortitude.pdf

Nick
[email protected]

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