Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Forreach loop with esttab


From   Roberto Ferrer <[email protected]>
To   Stata Help <[email protected]>
Subject   Re: st: Forreach loop with esttab
Date   Sun, 12 Jan 2014 10:26:50 -0430

Several things:

0. The user-written module ESTOUT, of which -esttab- is part, is
authored by Ben Jann and available in SSC. Although extremely popular,
the Statalist FAQ asks you to report where user-written commands come
from. Type -ssc describe estout- for a descrption.

1. I prefer

    foreach yvar of varlist  mpg price displacement    {

over

    foreach yvar in mpg price displacement {

simply because you are using a variable list, not any list. It doesn't
affect you here but you might want to read -help foreach-.

2.  I assume your code reads

    esttab `yvar'1 using example, t ...

and not

    esttab `yvar' using example, t ...

because you would be reporting a different error.

3. You are using the -replace- option, which does exactly that:
replace a file previously created. You might want to use -append-,
instead. This gives you several _stacked_ tables.

4. If you want side-by-side results, as suggested in -help estimates
store-, you can try -estimates table- :

clear all
set more off

sysuse auto

foreach yvar of varlist mpg price displacement {
    regress `yvar' foreign weight
    estimates store `yvar'1

    local storelist = "`storelist' `yvar'1"
}

estimates table `storelist', b(%7.4f) t(%7.4f) stats(F ll chi2 df_m df_r)


or get rid of the macro -storelist- and use the system variable _all.

On Sun, Jan 12, 2014 at 5:10 AM, Muhammad Ramzan <[email protected]> wrote:
> Assalam-o-Alaikum
>
> Hi Everyone I am using the foreach lopp command with esttab command.
> here in the final table i should get results of three equations. but
> here i am only getting the results of last euquation that is, in which
> is dependent variable is  " displacement ".
>
> foreach yvar in mpg price displacement {
> reg `yvar' foreign weight
> estimates store `yvar'1
>
> esttab `yvar' using example, t scalars(F ll chi2 df_m df_r) nodepvars  replace
>
> }
>
>
>
> Regards
> Muhammad Ramzan
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index