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]

st: RE: Creating a freqency table with multiple variables using esttab


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Creating a freqency table with multiple variables using esttab
Date   Fri, 23 Apr 2010 14:21:27 +0100

Sounds most like -tabout- (SSC). 

Nick 
[email protected] 

Jamie Fagg

I am trying to create a table with percentages and frequencies for
multiple variables across multiple datasets and I'd like to automate
this with Stata.

I would like to get from Ben Jann's very helpful basic online example
(adapted below) to the situation which I need (desired table presented
below the example).

I've searched the archives, but I haven't come up with anything which
describes the syntax for the esttab command for this, although it must
be a common issue.

Thanks for your time,

Jamie

I'd like to create this...

--------------------------------------

                   freq/pct
--------------------------------------
Car type
Domestic               52
                    70.27
Foreign                22
                    29.73
Total                     69
                    100.00
Repair Record (1978)
1                           2
                    2.90
2                           8
                    11.59
3                           30
                    43.48
4                          18
                    26.09
5                  11
                     15.94
Total             69
                     100.00

from this...

. esttab , cells(b(label(freq)) pct(fmt(2))) noobs

--------------------------------------
                      (1)          (2)
                  foreign        rep78
                 freq/pct     freq/pct
--------------------------------------
Domestic               48
                    69.57
Foreign                21
                    30.43
Total                  69           69
                   100.00       100.00
1                                    2
                                  2.90
2                                    8
                                 11.59
3                                   30
                                 43.48
4                                   18
                                 26.09
5                                   11
                                 15.94
--------------------------------------

as created by this...

. sysuse auto,clear
(1978 Automobile Data)
. mark touse
. markout touse foreign rep78
. eststo: estpost tabulate foreign if touse==1

    foreign |      e(b)     e(pct)  e(cumpct)
-------------+---------------------------------
    Domestic |        48   69.56522   69.56522
     Foreign |        21   30.43478        100
-------------+---------------------------------
       Total |        69        100
(est1 stored)

. eststo: estpost tabulate rep78  if touse==1

       rep78 |      e(b)     e(pct)  e(cumpct)
-------------+---------------------------------
           1 |         2   2.898551   2.898551
           2 |         8    11.5942   14.49275
           3 |        30   43.47826   57.97101
           4 |        18   26.08696   84.05797
           5 |        11   15.94203        100
-------------+---------------------------------
       Total |        69        100
(est2 stored)

. esttab , cells(b(label(freq)) pct(fmt(2))) noobs

--------------------------------------
                      (1)          (2)
                  foreign        rep78
                 freq/pct     freq/pct
--------------------------------------
Domestic               48
                    69.57
Foreign                21
                    30.43
Total                  69           69
                   100.00       100.00
1                                    2
                                  2.90
2                                    8
                                 11.59
3                                   30
                                 43.48
4                                   18
                                 26.09
5                                   11
                                 15.94
--------------------------------------


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index