Announcement

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

  • How to generate a table with means and medians by group, their difference, as well as significance levels?

    I want to replicate the following table:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	73.9 KB
ID:	1426843


    where the value in each cell is mean (and median in the brackets below it). I tried to generate the first two columns with

    Code:
    table log_mv_assets log_bv_assets log_sales log_1plus_age profit_margin ppe2bv_assets ///
    mkt2book rd2sales ad2sales equity2asset vol_asset access, contents(mean median)
    however, the response was "too many variables specified". For the third column, what I could do was making the test with commands -ttest- for means and -median- for medians. Is it possible to create the whole table efficiently? Some example data (with only 3 variables) is pasted:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(access log_mv_assets log_sales)
    0   2.98085  3.592038
    0  2.820389  3.620494
    0  3.083743  3.490672
    1  5.932678  5.697738
    1   6.27632  5.851168
    1   6.52489  6.007239
    1  6.292146  6.097794
    1  6.017305  6.145348
    1  5.999619  6.046561
    1  5.964461   5.94746
    1  6.124185  6.010664
    1  6.157353  6.112343
    1  6.376326  6.224539
    1  6.713152  6.378983
    1  7.004667  6.662012
    1  6.848636  6.822237
    1   6.65363  6.931797
    1  6.604878  6.773372
    0  3.273743  2.958342
    0 3.2325025  2.972975
    0  3.229954  3.347058
    0 3.6754775  3.594184
    0  3.719142  3.701845
    0  3.994174 3.5896666
    0 4.2457056  3.939774
    0  4.770752  4.281654
    0  5.003685 4.5231137
    0 1.9656384  1.541373
    0 1.3545295 1.0009995
    0 1.9495597  .9512717
    0  2.528778 1.1899753
    0  2.466764  1.290609
    0 4.7601376 1.8702625
    0  4.732373 2.8757656
    0 2.3755684  3.175927
    0  2.585845  3.311783
    0  2.903041  3.556519
    0 2.9565756  3.808683
    0  5.293977  4.967568
    0  5.466451  5.117173
    0  5.183933  5.192134
    0  5.466319  5.280092
    0  5.580708   5.55992
    0   6.03099  5.683032
    0  6.313433   5.75731
    0  6.975975  5.902956
    0   7.23284  6.106432
    0   7.86315  6.373699
    0    8.4355  6.719024
    0   8.43554  7.060004
    0  8.159143  7.229605
    0  8.942077  7.563692
    0  9.771268  8.098004
    0  2.906737 1.8870697
    0  3.470086  4.166743
    0   3.58313  4.188123
    0 4.4515176  4.685662
    0  4.539479  4.784462
    0  4.630643  4.919959
    0 4.6616216  4.797104
    0 4.5151114  4.971603
    0  4.423924  4.942442
    0   4.37963  4.731803
    0 4.3695097   4.82133
    0 4.5637465  4.842453
    0 3.3484645  2.762286
    0  3.329737  2.911263
    1  6.688932   6.00607
    1  6.875176  6.191094
    0  3.108257  2.823638
    0 3.1547825  2.977772
    0  3.599534  3.769768
    0  3.553103  3.816613
    0  3.538588  3.877266
    0 3.2033534 3.6384015
    0  3.165839  3.644353
    0 2.9962196 3.6443264
    0  2.745709 3.4178905
    0  2.547084 3.2804976
    0  3.200126 3.5981064
    0 3.2984054  3.612241
    0 2.9659944  3.519662
    1  5.597262  5.944103
    1   5.82066  6.208045
    0  3.516366  3.234985
    0  3.890677  3.403428
    0  4.079375  3.867925
    0  3.997347  3.872221
    0  3.826114  3.512828
    0 4.7372813  4.817228
    0  5.417011  5.068458
    0  5.573306  5.465872
    1  5.704102  5.584593
    1  5.891969  5.618432
    1  6.122792  5.671741
    1  6.029373  5.687355
    0  6.051079  5.823726
    0  6.524072  6.151164
    0  6.659762  6.255524
    0   6.43774  6.186587
    end

  • #2
    It would require a bit more of work. I usually accomplish that by writting small do scripts. I don't think there is a command in Stata to do that easily.

    Comment

    Working...
    X