Announcement

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

  • Exporting descriptive statistics to Word

    Dear all,

    I have been trying to export the panel descriptive statistics from Stata to word but I was not able to do it. Here is an example of my data:


    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int year float id long x1 double(x2 x3)
    2000 1 35420 1446.1338317266648 119851.7
    2001 1 35160 1510.353578650355 122915.5
    2002 1 37600 1453.0436783733537 127505
    2003 1 37260 1424.7504880103013 134152.6
    2004 1 36630 1549.031513471673 147715.2
    2005 1 37150 1701.198847653237 158846.8
    2006 1 37950 1842.6681811828564 166469
    2007 1 42210 1897.8424255912892 172975.2
    2008 1 44480 1922.4531527449205 174526.3
    2009 1 39980 1745.807952940959 170930.9
    2010 1 40930 1759.4580226909795 177249.2
    2011 1 42590 1798.4641354501023 183916.6
    2012 1 43460 1878.7596810385348 189245.5
    2013 1 41380 1917.8938344469084 194786.9
    2014 1 42280 1919.3540029113885 197406.9
    2015 1 44510 2009.4407538266746 202372.4
    2016 1 47220 2127.7360759296 207368.4
    2017 1 50870 2135.5283909004306 214606.3
    2018 1 49940 2260.101749356247 223859.3
    2019 1 56200 2400.6324413478906 231561.9
    2020 1 54690 2470.4188403008043 230892.1
    2021 1 56930 2827.713652535568 254109.7
    2000 2 52850 2266.5141099077496 26806.6
    2001 2 57360 2254.4838838971523 28494.1
    2002 2 52770 1696.1563789724087 29756.8
    2003 2 51840 1727.4966302393225 32037.9
    2004 2 55060 2037.3419123111973 35302.4
    2005 2 55890 2786.299040701946 40356.6
    2006 2 56420 3678.979182647171 45094.1
    2007 2 62990 5421.794796413347 49583.7
    2008 2 63990 12702.4823442989 55122.5
    2009 2 61600 7091.027979882529 49957.8
    2010 2 57850 6334.791353283416 53331.6
    2011 2 57430 7666.20982378324 56896.3
    2012 2 63650 9646.006485953942 58283.6
    2013 2 61140 6958.554877403996 57247.7
    2014 2 67630 4603.153003425703 56484.9
    2015 2 75110 1846.2819766260852 51490.9
    2016 2 75720 1207.852405480928 50727.7
    2017 2 77990 1631.5205612004593 53301.5
    2018 2 68730 2248.5718629857297 54899.6
    2019 2 78390 2427.6222970734852 54728.2
    2020 2 74750 1825.4835543067634 50475.2
    2021 2 81130 1437.7491732328065 57349.4
    2000 3 39780 1569.7320033035007 165110.7
    2001 3 42700 1585.363129487433 171909.6
    2002 3 39730 1570.9637517129936 180522.3
    2003 3 41170 1577.3478848221278 193634.9
    2004 3 43850 1705.0035701623592 206541.1
    2005 3 45250 1885.3027627482907 227915.9
    2006 3 46660 2215.171613999407 245957
    2007 3 47220 2335.557886343344 261392
    2008 3 46910 2094.3491792352097 262926
    2009 3 45740 1755.341743240035 246424.3
    2010 3 46900 1673.0741077969617 251153
    2011 3 48620 1894.7058245600158 260915.7
    2012 3 47040 1982.2664887626395 271440
    2013 3 50600 2030.492758516223 278591.6
    2014 3 49250 1993.8399253929192 287666.6
    2015 3 52250 2008.1433553691675 299393.3
    2016 3 57100 2162.7376411620435 313081.4
    2017 3 59700 2170.6610360143063 332001.8
    2018 3 62280 2276.6081704825697 351879.5
    2019 3 70670 2490.989315046964 372393.5
    2020 3 67090 2457.5744505492207 382072.3
    2021 3 70820 2861.0089226471196 420026.7
    2000 4 29700 1818.3315239223052 68678.5
    2001 4 33340 1852.7272734027822 70616.7
    2002 4 32390 1912.8564813463188 74113.9
    2003 4 32000 1888.404207843759 78695.1
    2004 4 34980 2029.5691944462021 85199.6
    2005 4 36660 2351.1297879937306 90887.7
    2006 4 37060 2486.3129797314514 95875.1
    2007 4 40800 2594.8354483702806 98381.6
    2008 4 39590 2619.7121362131306 99706.8
    2009 4 36540 2577.8680446265125 97508.1
    2010 4 38590 2587.2358571087316 101486.5
    2011 4 41300 2704.087468438014 105768.1
    2012 4 39020 2806.668481846173 108492.1
    2013 4 39920 2900.363423374551 113227.3
    2014 4 44920 3003.7204097739154 116139.4
    2015 4 42800 3076.978063799026 117786.8
    2016 4 45910 3152.2112831174386 119152.4
    2017 4 49750 3168.0227574233772 122466.7
    2018 4 49780 3259.880198966788 127535.7
    2019 4 54540 3382.296171612901 131578.3
    2020 4 50780 3404.5037035659934 133969.1
    2021 4 50780 3875.4462735108436 148676.1
    2000 5 46820 2465.811925199314 1356975.4
    2001 5 47260 2623.40974153364 1375761.3
    2002 5 47440 2229.74667556286 1418429.6
    2003 5 49300 2246.5576772850345 1497918.7
    2004 5 49220 2409.6276790480933 1588177.4
    2005 5 51760 2747.427754923022 1698560.4
    2006 5 55320 3091.147735714094 1812210
    2007 5 55730 3165.130941911091 1898902
    2008 5 57010 3206.231436455194 1944695.3
    2009 5 56130 2732.7949241081783 1890165.9
    2010 5 54280 2872.36756606122 1954092.7
    2011 5 53370 3166.199949830365 2023500
    end
    [/CODE]

    How can I export the output of the below command to Word? I tried putdocx but it did not work.

    Code:
      tabstat x1 x2 x3, stats (mean sd min p50 max  skewness kurtosis) by(id) save
    Many thanks in advance,

  • #2
    If you have Stata 17 or newer, you can use the new collect features in the reimagined table command to produce a table similar to the one you mention from tabstat.

    Here is an example, based on your dataset.
    Code:
    . local vlist x1 x2 x3
    
    . table (id result) (var), ///
    >         statistic(mean `vlist') ///
    >         statistic(sd `vlist') ///
    >         statistic(min `vlist') ///
    >         statistic(p50 `vlist') ///
    >         statistic(max `vlist') ///
    >         statistic(skewness `vlist') ///
    >         statistic(kurtosis `vlist')
    
    -----------------------------------------------------------
                           |         x1          x2          x3
    -----------------------+-----------------------------------
    id                     |                                   
      1                    |                                   
        Mean               |   43401.82    1909.036    181966.5
        Standard deviation |   6664.232    357.8231    37305.18
        Minimum value      |      35160     1424.75    119851.7
        50th percentile    |      42245    1888.301    180582.9
        Maximum value      |      56930    2827.714    254109.7
        Skewness           |   .7386411    .7462483    -.020012
        Kurtosis           |   2.469764    3.285532    2.229944
      2                    |                                   
        Mean               |   64104.09    4068.017    47624.05
        Standard deviation |   9384.653    3116.192    10475.09
        Minimum value      |      51840    1207.852     26806.6
        50th percentile    |      62295    2347.068     51109.3
        Maximum value      |      81130    12702.48     58283.6
        Skewness           |   .4371312    1.276751   -.9160442
        Kurtosis           |   1.831648    3.807905    2.335052
      3                    |                                   
        Mean               |   50969.55    2013.465    271952.2
        Standard deviation |   9516.435    344.1225    69378.35
        Minimum value      |      39730    1569.732    165110.7
        50th percentile    |      47130    2000.992      262159
        Maximum value      |      70820    2861.009    420026.7
        Skewness           |   .9409129    .5354121    .3706627
        Kurtosis           |   2.726843    2.844208     2.47196
      4                    |                                   
        Mean               |   40961.36    2702.416    104815.5
        Standard deviation |   6955.515    569.1173    21597.95
        Minimum value      |      29700    1818.332     68678.5
        50th percentile    |      39755      2661.9    103627.3
        Maximum value      |      54540    3875.446    148676.1
        Skewness           |   .3283458    .0076747    .0340536
        Kurtosis           |   2.111046     2.25729     2.29643
      5                    |                                   
        Mean               |      51970    2746.371     1704949
        Standard deviation |   3805.814    359.5404    247264.1
        Minimum value      |      46820    2229.747     1356975
        50th percentile    |      52565    2740.111     1755385
        Maximum value      |      57010    3206.231     2023500
        Skewness           |  -.1171979   -.0760307   -.2219675
        Kurtosis           |   1.431192    1.625216    1.468355
      Total                |                                   
        Mean               |    50112.5     2682.01    337992.7
        Standard deviation |   11484.17    1689.606    521462.4
        Minimum value      |      29700    1207.852     26806.6
        50th percentile    |      48920    2247.565    161978.8
        Maximum value      |      81130    12702.48     2023500
        Skewness           |   .6992171    3.521276    2.321529
        Kurtosis           |   3.044137    17.59767    6.836913
    -----------------------------------------------------------
    This call to table created a new collection named Table that you can customize with collect commands then publish to Word via collect export or with putdocx collect.

    In Stata, type the following to get more details about publishing your custom tables to Word.
    Code:
    . help collect export
    . help putdocx collect

    Comment

    Working...
    X