Announcement

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

  • Summary statistics table with classification of variables in the rows

    Hello everyone,

    I'm interested in creating a table of mean, median, and standard deviations for a set of variables placed in the rows obtained for the values of the variables in the columns and their constraint conditions using their labels for all variables and variables in the columns, printed in a wide left anticlockwise orientation, that can be imported into a latex document.

    What I would like is to create classification of variables in the rows, such as classification A and from below their variables; classification B and from below their variables, etc., using their labels; and variables in the columns, to be printed in a wide left anticlockwise orientation,in latex. In an identical table here https://www.statalist.org/forums/for...35#post1729135
    Jeff Pitblado (StataCorp) helped me to create a table for correlation. I would need the same table, only this time for summary statistics.

    To provide more clarity in the analysis, for the purpose of the table, I work with a panel where I have id, year, country, and variables, and I only classify variables in the rows. I do not have a group variable in the dataset or other
    The wanted layout is the following one, for which I provide a data example:

    Variables in the columns are
    Index1 index1>0 index 1<0 Index2 index2>0 index 2<0 index 3. index 4 cat

    Variables in the rows classification should be : “Whatever nameA “ fd ka , “Whatever nameB” ext dom, “Whatever nameC” pr la, “Whatever nameD” ext dom pr la, “Whatever nameE” dom pr la



    cat is a categorical variable of the measure of an event duration in years . Therefore, for cat I would need the statistics for itself as a whole and for each year . In my real data I have five classifications, so I imitate five classifications in the rows. If factor variables for cat are not allowed, then generate by tab new varialbes or any other approach is an accepted solution.


    Wanted Layout


    Index1 index1>0 index 1<0 Index2 index2>0 index 2<0 index 3 index 4 i.cat
    “Whatever nameA “
    fd
    ka

    “Whatever nameB”
    ext
    dom


    “Whatever nameC”
    pr
    la


    “Whatever nameD”
    ext
    dom
    pr
    la

    “Whatever nameE”
    dom
    pr
    la
    etc









    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(year id) str97 country str1 group float(fd ka ext dom pr la index1 index2 index3 index4) byte cat
    1992 1 "Country1" "A"   .524175   2.321955  .75 .7777778 .071428575        1       12.2        6.5         0        1 5
    1993 1 "Country1" "A"  .5846328   2.321955  .75 .7777778 .071428575        1  17.553352          0         0        1 2
    1994 1 "Country1" "A"  .6478685   2.321955  .75 .9444444 .071428575 .7912164      19.11        8.6         0        1 4
    2000 1 "Country1" "A"  .8414965   1.048859  .75        1  .53571427 .7782844     28.634     -9.788         0        1 3
    2001 1 "Country1" "A"   .873997   1.048859  .75        1   .6190476 .7782844   26.41307   6.464286         0        1 5
    2002 1 "Country1" "A"  .8985876   1.048859  .75        1   .6190476 .7661784   5.536341          0         0        1 2
    2003 1 "Country1" "A"  .9015374   1.048859  .75        1   .6190476 .7661784   5.536341 -14.278473         0        1 3
    2004 1 "Country1" "A"  .9041975   1.048859  .75        1   .6190476 .7661784   7.350179  2.7697804         0        1 4
    2010 1 "Country1" "A"   .941813   1.048859 .875        1   .8452381 .7704133   6.241802        5.2         0        1 5
    2011 1 "Country1" "A"   .934702   1.048859 .875        1   .8452381 .7704133      5.068          0         0        1 2
    2012 1 "Country1" "A"  .9079577   1.303478 .875        1   .8452381 .7704133      5.068    -21.986         0        1 3
    2013 1 "Country1" "A"  .8901507  1.5580974 .875        1   .8452381 .7694158   7.929047       -4.5         0        1 4
    1992 2 "Country2" "A"   .399736   .6099069 .875 .7777778          0 .5697657        1.6          0         0        1 2
    1993 2 "Country2" "A"   .461959  2.0673358 .875 .9444444          0 .5697657   6.996447        5.2         0        1 5
    1994 2 "Country2" "A"  .4953545   2.321955 .875 .9444444          0 .5697657    8.69136    -21.986         0        1 3
    2000 2 "Country2" "A"  .7018992   2.321955    1        1   .4404762 .5697657   2.364474       -4.5         0        1 4
    2001 2 "Country2" "A"  .7035186   2.321955    1        1   .5952381 .5697657   2.364474          0         1        0 2
    2002 2 "Country2" "A"  .6993845   2.321955    1        1   .5952381 .5457992  -.7668521  29.073414 .49041095  .509589 5
    2003 2 "Country2" "A"  .7077955   2.321955    1        1   .5952381 .5457992 -2.9592714  18.228453         0        1 4
    2004 2 "Country2" "A"   .728983   2.321955    1        1   .5952381 .5457992  -2.950783  -6.882123         0        1 3
    2010 2 "Country2" "A"  .7894757   2.321955    1 .9444444   .9166667 .5718316      3.891  31.695776         0        1 5
    2011 2 "Country2" "A"  .8007692   2.321955    1 .9444444   .9166667 .5718316      3.891          0         1        0 2
    2012 2 "Country2" "A"  .7593077   2.321955    1 .9444444   .9166667 .5718316 -2.5410414     22.593         0        1 4
    2013 2 "Country2" "A"  .7435991   2.321955    1 .9444444   .9166667 .5718316  -6.333579     -7.235         0        1 3
    1992 3 "Country3" "B"  .5840359   2.321955    1 .7777778  .08333334 .6281998   .3835026     29.936         0        1 3
    1993 3 "Country3" "B"  .6147648   2.321955    1 .8888889  .08333334 .6281998   .3835026          0 .21153846 .7884616 2
    1994 3 "Country3" "B"   .632942   2.321955    1 .8888889  .08333334 .6260909   .8169867    27.6381         0        1 4
    2000 3 "Country3" "B"  .7692201   2.321955    1 .8888889        .75 .6297867  1.9049623     -7.235 .33516484 .6648352 3
    2001 3 "Country3" "B"  .7502941   2.321955    1 .8888889        .75 .6297867  1.9049622          0  .4917582 .5082418 2
    2002 3 "Country3" "B"  .7244223   2.321955    1 .8888889   .8333333 .6297867   1.283737  14.872792  .3763736 .6236264 3
    2003 3 "Country3" "B"  .7401305   2.321955    1 .8888889   .8333333 .6297867 -1.3254085     48.458         0        1 4
    2004 3 "Country3" "B"  .7518873   2.321955    1 .8888889   .8333333 .6547069 -1.3254085  -8.191456         1        0 3
    2010 3 "Country3" "B"  .7356597   2.321955    1 .9444444          1 .6547069  1.1606808          0         1        0 2
    2011 3 "Country3" "B"  .7201834   2.321955    1 .9444444          1 .6547069  1.1606808      5.187         0        1 4
    2012 3 "Country3" "B"  .7283527   2.321955    1 .9444444          1 .6547069  1.1606808     31.889         0        1 4
    2013 3 "Country3" "B"  .7077386   2.321955    1 .9444444          1 .6547069  1.1165322    -29.707         1        0 3
    1992 4 "Country4" "B"  .3452282   .6099069 .875 .5555556 .071428575 .6121462   2.615249      5.187         0        1 4
    1993 4 "Country4" "B"  .3790323  2.0673358    1 .7222222 .071428575 .6121462  1.4437795          0         1        0 2
    1994 4 "Country5" "C"  .4175321   2.321955    1 .7222222 .071428575 .6121462  4.0116615   29.87246         0        1 4
    2000 4 "Country5" "C"   .759881   2.321955    1 .8888889   .7619048 .6121462    5.97681    -29.707         1        0 3
    2001 4 "Country5" "C"  .7410694   2.321955    1 .8888889   .7619048 .6121462   7.402936          0         1        0 2
    2002 4 "Country5" "C"  .7281089   2.321955    1 .8888889   .8333333 .6121462      8.534          .         .        . 4
    2003 4 "Country5" "C"   .735869   2.321955    1 .8888889   .8333333 .6263371      8.534      5.674         0        1 4
    2004 4 "Country5" "C"  .7334849   2.321955    1 .8888889   .8333333 .6263371      8.534 -21.978655         1        0 3
    2010 4 "Country5" "C"  .7798166   2.321955    1 .9444444   .9166667 .6263371     -16.25          0         1        0 3
    2011 4 "Country5" "C"  .7637033   2.321955    1 .9444444   .9166667 .6263371 -14.330358          .         .        . 4
    2012 4 "Country5" "C"  .7608096   2.321955    1 .9444444   .9166667 .6263371          0      5.674         0        1 4
    2013 4 "Country5" "C"  .7455279   2.321955    1        1   .9166667  .607849   .6806767     37.456         1        0 3
    1992 5 "Country6" "C"  .1757301          .    .        .          .        .          .          .         .        . 3
    1993 5 "Country6" "C"  .1761862          .    .        .          .        .          .          .         .        . 3
    1994 5 "Country6" "C"  .1562944          .    .        .          .        .          .  -6.130934  .2967033 .7032967 4
    2000 5 "Country6" "C"  .2008834 -1.2261546    .        .          .        .          .     37.456         1        0 3
    2001 5 "Country6" "C" .17261477 -1.2261546    .        .          .        .          .          .         .        . 3
    2002 5 "Country6" "C" .21249928 -1.2261546    .        .          .        .          .          .         .        . 3
    2003 5 "Country6" "C"  .2206576 -.02334493    .        .          .        .          .    -34.113         1        0 4
    2004 5 "Country6" "C" .23541167 -.02334493    .        .          .        .          .  35.647743         1        0 3
    2010 5 "Country6" "C" .27683625   1.249751    .        .          .        .          .          .         .        . 3
    2011 5 "Country6" "C" .27487376   1.249751    .        .          .        .          .          .         .        . 3
    2012 5 "Country6" "C" .27767062   1.249751    .        .          .        .          .    -34.113         1        0 4
    2013 5 "Country6" "C"  .2884341   1.249751    .        .          .        .          .     -1.262         1        0 3
    1992 6 "Country7" "C" .25534174  -.1539507 .625       .5          0 .8271327          .          .         .        . 2
    1993 6 "Country7" "C" .28078705  -.1539507 .625       .5  .16666667 .8271327          .          .         .        . 3
    1994 6 "Country7" "C"  .3567602  -.1539507 .625 .5555556  .16666667 .8271327          . -17.802141  .7142857 .2857143 4
    2000 6 "Country7" "C"  .4190661 -1.2261546 .625 .6111111  .23809524 .8271327          .     -1.262         1        0 3
    2001 6 "Country7" "C"  .3738855 -1.2261546 .625 .6666667   .3928571 .8271327          .          .         .        . 2
    2002 6 "Country7" "C"   .404098 -1.2261546 .625 .6666667   .3928571 .8271327          .          .         .        . 3
    2003 6 "Country7" "C"  .4157713 -1.2261546 .875 .6666667   .3928571 .7653575          .     22.975         0        1 4
    2004 6 "Country7" "C"  .4085605 -1.2261546 .875 .6666667  .53571427 .7653575          .  -2.527769         1        0 3
    2010 6 "Country7" "C"  .4888775 -.02334493 .875 .6666667   .7619048 .7653575          .          .         .        . .
    2011 6 "Country7" "C"  .4789392 -.02334493 .875 .6666667   .7619048 .7653575          .          .         .        . .
    2012 6 "Country7" "C"  .4922497 -.02334493 .875 .6666667   .7619048 .7653575          .          .         .        . .
    2013 6 "Country7" "C"   .508882 -.02334493  .75 .6666667   .7619048 .7653575          .          .         .        . .
    1992 7 "Country8" "D" .56565696   2.321955    1 .9444444   .7738096 .8009957  13.403038          .         .        . .
    1993 7 "Country8" "D"  .6403931   2.321955    1 .9444444   .7738096 .8070084       12.1          .         .        . .
    1994 7 "Country8" "D"  .6921942   2.321955    1 .9444444   .8452381 .8070084       12.1          .         .        . .
    2000 7 "Country8" "D"  .8552948   2.321955    1        1   .9285714 .8314556      1.806          .         .        . .
    2001 7 "Country8" "D"  .8805222   2.321955    1        1   .9285714 .8314556   1.958802          .         .        . .
    2002 7 "Country8" "D"  .8265579   2.321955    1        1   .9285714 .8314556      2.076          .         .        . .
    2003 7 "Country8" "D"  .8580942   2.321955    1        1          1 .8314556      2.076          .         .        . .
    2004 7 "Country8" "D"  .8708485   2.321955    1        1          1 .8314556      2.076          .         .        . .
    2010 7 "Country8" "D"  .8683383   2.321955    1        1          1 .8314556   3.564247          .         .        . .
    2011 7 "Country8" "D"  .8672714   2.321955    1 .9444444          1 .8314556   5.454876          .         .        . .
    2012 7 "Country8" "D"  .8684435   2.321955    1 .8888889          1 .8429364   5.454876          .         .        . .
    2013 7 "Country8" "D"  .8866873   2.321955    1 .9444444          1 .8429364   5.454876          .         .        . .
    1992 8 "Country8" "D"  .5748482   2.321955    1 .8888889  .52380955 .9702252       14.9          .         .        . .
    1993 8 "Country8" "D"  .6702072   2.321955    1 .8888889  .52380955 .9702252   .0375137          .         .        . .
    1994 8 "Country8" "D"  .6812267   2.321955    1 .8888889  .52380955 .9702252      -.781          .         .        . .
    2000 8 "Country8" "D"  .8790284   2.321955    1        1        .75 .9702252      1.463          .         .        . .
    2001 8 "Country8" "D"   .889005   2.321955    1        1        .75 .9702252   5.542341          .         .        . .
    2002 8 "Country8" "D"  .8849987   2.321955    1        1        .75 .9702252      5.767          .         .        . .
    2003 8 "Country8" "D"  .8916724   2.321955    1        1        .75 .9702252      5.767          .         .        . .
    2004 8 "Country8" "D"  .8910962   2.321955    1        1        .75 .9702252      5.767          .         .        . .
    2010 8 "Country8" "D"  .8951228   2.321955    1        1   .8333333 .9702252       -.36          .         .        . .
    2011 8 "Country8" "D"  .8785759   2.321955    1        1   .8333333 .9702252       -.36          .         .        . .
    2012 8 "Country8" "D"  .8894278   2.321955    1        1   .8333333 .9702252       -.36          .         .        . .
    2013 8 "Country8" "D"  .8901961   2.321955    1        1   .8333333 .9702252   1.298654          .         .        . .
    end
    ------------------ copy up to and including the previous line ------------------


Working...
X