Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Descriptive Statistics tables and packages

    I am looking to a table that shows the mean, median, r(25), r(75), and SD for my variable by Industry. So the rows should show the industry values for column variables DACC.

    I tried the below commands but its give me output separately not in a single table

    Code:
    by Industry, sort : summarize DACC
    Code:
    tabstat DACC, stats(n mean median min max)
    Code:
    univar DACC, by(SICCode)
    Note: Since univar can not take string variable, the SICCode variable is a numeric coding to the respective Industries

    Below are my data which is in panel structure

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str9 Ticker int Year str23 Industry byte SICCode float DACC
    "TH:2S"    1995 "Industrials"             11           .
    "TH:2S"    1996 "Industrials"             11           .
    "TH:2S"    1997 "Industrials"             11           .
    "TH:2S"    1998 "Industrials"             11           .
    "TH:2S"    1999 "Industrials"             11           .
    "TH:2S"    2000 "Industrials"             11           .
    "TH:2S"    2001 "Industrials"             11           .
    "TH:2S"    2002 "Industrials"             11           .
    "TH:2S"    2003 "Industrials"             11           .
    "TH:2S"    2004 "Industrials"             11           .
    "TH:2S"    2005 "Industrials"             11           .
    "TH:2S"    2006 "Industrials"             11           .
    "TH:2S"    2007 "Industrials"             11  -.08454061
    "TH:2S"    2008 "Industrials"             11  -.25864583
    "TH:2S"    2009 "Industrials"             11    .6085715
    "TH:2S"    2010 "Industrials"             11   .09650405
    "TH:2S"    2011 "Industrials"             11   -.1017216
    "TH:2S"    2012 "Industrials"             11   .11378127
    "TH:2S"    2013 "Industrials"             11  -.05965737
    "TH:2S"    2014 "Industrials"             11  -.04307863
    "TH:A"     1995 "Property & Construction" 77           .
    "TH:A"     1996 "Property & Construction" 77           .
    "TH:A"     1997 "Property & Construction" 77           .
    "TH:A"     1998 "Property & Construction" 77           .
    "TH:A"     1999 "Property & Construction" 77           .
    "TH:A"     2000 "Property & Construction" 77           .
    "TH:A"     2001 "Property & Construction" 77           .
    "TH:A"     2002 "Property & Construction" 77           .
    "TH:A"     2003 "Property & Construction" 77           .
    "TH:A"     2004 "Property & Construction" 77    .7635902
    "TH:A"     2005 "Property & Construction" 77   .06726224
    "TH:A"     2006 "Property & Construction" 77   -.1024842
    "TH:A"     2007 "Property & Construction" 77   .09083974
    "TH:A"     2008 "Property & Construction" 77  -.02267651
    "TH:A"     2009 "Property & Construction" 77  -.15725097
    "TH:A"     2010 "Property & Construction" 77    .0957468
    "TH:A"     2011 "Property & Construction" 77  .032091457
    "TH:A"     2012 "Property & Construction" 77    .1184249
    "TH:A"     2013 "Property & Construction" 77    .2663026
    "TH:A"     2014 "Property & Construction" 77    .2288631
    "TH:AA"    1995 "Industrials"             11    .1406714
    "TH:AA"    1996 "Industrials"             11    .0505299
    "TH:AA"    1997 "Industrials"             11   .11710031
    "TH:AA"    1998 "Industrials"             11   .14672938
    "TH:AA"    1999 "Industrials"             11  -.05598317
    "TH:AA"    2000 "Industrials"             11  -.01284377
    "TH:AA"    2001 "Industrials"             11  .004790202
    "TH:AA"    2002 "Industrials"             11   .05033767
    "TH:AA"    2003 "Industrials"             11   .04497265
    "TH:AA"    2004 "Industrials"             11  -.12834519
    "TH:AA"    2005 "Industrials"             11   .05263968
    "TH:AA"    2006 "Industrials"             11   .09047706
    "TH:AA"    2007 "Industrials"             11  .011825196
    "TH:AA"    2008 "Industrials"             11           .
    "TH:AA"    2009 "Industrials"             11           .
    "TH:AA"    2010 "Industrials"             11           .
    "TH:AA"    2011 "Industrials"             11           .
    "TH:AA"    2012 "Industrials"             11           .
    "TH:AA"    2013 "Industrials"             11           .
    "TH:AA"    2014 "Industrials"             11           .
    "TH:AAV"   1995 "Services"                55           .
    "TH:AAV"   1996 "Services"                55           .
    "TH:AAV"   1997 "Services"                55           .
    "TH:AAV"   1998 "Services"                55           .
    "TH:AAV"   1999 "Services"                55           .
    "TH:AAV"   2000 "Services"                55           .
    "TH:AAV"   2001 "Services"                55           .
    "TH:AAV"   2002 "Services"                55           .
    "TH:AAV"   2003 "Services"                55           .
    "TH:AAV"   2004 "Services"                55           .
    "TH:AAV"   2005 "Services"                55           .
    "TH:AAV"   2006 "Services"                55           .
    "TH:AAV"   2007 "Services"                55           .
    "TH:AAV"   2008 "Services"                55           .
    "TH:AAV"   2009 "Services"                55           .
    "TH:AAV"   2010 "Services"                55   1.0919831
    "TH:AAV"   2011 "Services"                55   .28426614
    "TH:AAV"   2012 "Services"                55     3.43393
    "TH:AAV"   2013 "Services"                55  -.03935567
    "TH:AAV"   2014 "Services"                55 -.017541166
    "TH:ABICO" 1995 "Agro & Food Industry"    22           .
    "TH:ABICO" 1996 "Agro & Food Industry"    22           .
    "TH:ABICO" 1997 "Agro & Food Industry"    22           .
    "TH:ABICO" 1998 "Agro & Food Industry"    22           .
    "TH:ABICO" 1999 "Agro & Food Industry"    22           .
    "TH:ABICO" 2000 "Agro & Food Industry"    22           .
    "TH:ABICO" 2001 "Agro & Food Industry"    22    .3811837
    "TH:ABICO" 2002 "Agro & Food Industry"    22 -.068777665
    "TH:ABICO" 2003 "Agro & Food Industry"    22   -.1509448
    "TH:ABICO" 2004 "Agro & Food Industry"    22  -1.1338484
    "TH:ABICO" 2005 "Agro & Food Industry"    22    .6798385
    "TH:ABICO" 2006 "Agro & Food Industry"    22 -.013820863
    "TH:ABICO" 2007 "Agro & Food Industry"    22  .066848315
    "TH:ABICO" 2008 "Agro & Food Industry"    22   -.1630021
    "TH:ABICO" 2009 "Agro & Food Industry"    22    .1760944
    "TH:ABICO" 2010 "Agro & Food Industry"    22  .027172344
    "TH:ABICO" 2011 "Agro & Food Industry"    22    .1821229
    "TH:ABICO" 2012 "Agro & Food Industry"    22    .2805742
    "TH:ABICO" 2013 "Agro & Food Industry"    22   .04285799
    "TH:ABICO" 2014 "Agro & Food Industry"    22   .06678031
    end
    format %ty Year
    Below is an example of roughly what I am trying to achieve.


    Click image for larger version

Name:	Screen Shot 2565-03-30 at 14.19.19.png
Views:	1
Size:	135.8 KB
ID:	1656941


    Thank you for your help and advice well in advance

  • #2
    Code:
    table (Industry), stat(mean DACC) stat(sd DACC) stat(q1 DACC) stat(q2 DACC) stat(q3 DACC)
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten Buis Thank you, this works perfectly

      Comment


      • #4
        Maarten Buis Some followup questions:

        So I am trying to export the tables to a word doc and using the following commands

        Code:
         putdocx begin
        then used

        Code:
        putdocx table Table1=etable, border()
        However, I am coming up with an error as below "last estimates not found". What I understand from here there is no table on memory. Is there is any way around this or do you have any advice on any other exporting means ?

        Secondly, is there is any command you would advise me to look into to change the titles of the stats such as "First quartile" ? I want to replace the title "first quartile" to "25%" just for presentation purpose.

        Thank you in advance for your advise

        Comment

        Working...
        X