Announcement

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

  • Descriptive statistics table generation

    Hello everyone,

    I need to generate a comprehensive descriptive statistics table based on a panel table as the picture shows(please see the end of the post, thanks):

    An extract of the variables are like the follows:
    Code:
    input long audit_fee float ln_AF double total_assets float ln_TA long net_income float(ln_NI busy chTA big_4)
     1         0    7217  8.884194   2058   7.62949 1   2096 0
     2  .6931472    5121  8.541105    479    6.1717 1      . 0
    18  2.890372    4040     8.304   -411         . 1      . 0
    20  2.995732   10100  9.220291   4352   8.37839 1      . 0
    21 3.0445225   16694  9.722805   8022 8.9899435 1   6594 0
    24  3.178054  217040 12.287837  -8403         . 1      . 1
    25  3.218876    1907  7.553287    -20         . 1      . 0
    I have code like this:
    Code:
    ssc install estout
    eststo summstats: estpost summarize audit_fee ln_AF total_asset ln_TA net_income ln_NI busy chTA big_4
    eststo big_4: estpost summarize audit_fee ln_AF total_asset ln_TA net_income ln_NI busy chTA  if big_4==1
    eststo non_big_4: estpost summarize  audit_fee ln_AF total_asset ln_TA net_income ln_NI busy chTA  if big_4==0
    esttab summstats big_4 non_big_4 using descriptive statistics.rtf, replace main(mean %6.2f) aux(sd) mtitle("Total sample" "Big Four clients" "Non-Big Four clients")
    esttab summstats big_4 non_big_4 using descriptive statistics.rtf, replace cell("mean sd") mtitle("Total sample" "Big Four clients" "Non-Big Four clients")
    Now I can't figure out how to add another statistic, namely the median for each variable.
    Could anyone help me out with this one?
    Thanks a lot in advance.

    Sample descriptive statistics:
    Click image for larger version

Name:	image_7891.png
Views:	1
Size:	343.9 KB
ID:	1395254


    Last edited by Lang Ding; 29 May 2017, 08:55.

  • #2
    It seems to me that
    Code:
    estpost tabstat ..., statistics(median)
    would be a starting point.

    Comment


    • #3
      Originally posted by William Lisowski View Post
      It seems to me that
      Code:
      estpost tabstat ..., statistics(median)
      would be a starting point.
      William Lisowski
      Thank you very much for your suggestion.
      Though it still occurs unclear to me how to insert the median statistics (1)into the descriptive statistics.rtf just as the mean and standard deviation values,and
      (2)to calculate the median by subgroups "Big Four clients","Non-Big Four clients" and "Total sample"

      As you suggested I added:
      Code:
      estpost tabstat audit_fee ln_AF total_asset ln_TA net_income ln_NI busy chTA big_4, statistics(median)
      Stata gives me:
      Code:
      Summary statistics: p50
           for variables: audit_fee ln_AF total_assets ln_TA net_income ln_NI busy chTA big_4
      
                   | e(audit~)   e(ln_AF)  e(total~)   e(ln_TA)  e(net_i~)   e(ln_NI)    e(busy)    e(chTA)   e(big_4)
      -------------+---------------------------------------------------------------------------------------------------
               p50 |       348   5.852202   253492.5   12.44308       7199   9.585268          1       6836          1
      Would you be so kind and give me a further hint?

      Thank you.

      Comment


      • #4
        I'm not an expert on esttab, but a reading of the help file suggests that to achieve what you want you're going to have to move to using estout, the more powerful command on which esttab is based. But I'm no expert on estout either so perhaps someone else can give some guidance.

        Comment


        • #5
          William Lisowski
          Thank you anyway

          Comment


          • #6
            In case someone needs: the median is given by p50:
            Code:
            esttab using file.xls, collabels("Mean" "Median" "N") cells("mean(fmt(3)) p50(fmt(3)) count(fmt(0))")
            Best Regards,

            Pedro
            (StataMP 16 user)

            Comment

            Working...
            X