Announcement

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

  • Creating personalized descriptive tables and export them to Latex

    Hello everyone.

    I am trying to get descriptive tables for my PhD thesis, but I would like very specific ones (not with mean, sd, min, max etc). Also, I would like to export them to Latex.
    1. Tables construction
    Here is my database format.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year str59 Origin float(WoundedQuinq_or VictimsQuinq_or TotalVictims_or AttacksQuinq_or WeapBombQuinq_or TargViolPolQuinq_or TargReligQuinq_or PropvalueQuinq_or)
    1990 "Afghanistan"           192   138   330   22   20 1  0    2235000
    1995 "Afghanistan"           464   151   615   80   45 3  4          0
    2000 "Afghanistan"           148    87   235   21   15 1  0          0
    2005 "Afghanistan"           816   724  1540  254  166 0  7       -891
    2010 "Afghanistan"          5405  4448  9853 1694  905 0 43     121981
    2015 "Afghanistan"         17729 15216 32945 5692 3460 6 61 -122989.96
    2017 "Afghanistan"         13472 12329 25801 3542 1562 4 73     591991
    1990 "Albania"                 0     0     0    0    0 0  0          0
    1995 "Albania"                 0     2     2    7    4 0  0          0
    2000 "Albania"               124    39   163   57   33 0  1          0
    2005 "Albania"                 0     0     0    4    3 0  0          0
    2010 "Albania"                 0     0     0    1    1 0  0          0
    2015 "Albania"                 2     1     3    3    3 0  0       -198
    2017 "Albania"                 0     0     0    6    5 0  0    3299802
    1990 "Algeria"                 0     0     0    0    0 0  0          0
    1995 "Algeria"               491   828  1319  497   48 1  7    5444000
    2000 "Algeria"              5314  6631 11945  915  363 2 21          0
    2005 "Algeria"              1147  2202  3349  525  161 0  3        -99
    2010 "Algeria"              1663  1145  2808  595  370 0  1       -891
    2015 "Algeria"               437   302   739  191  132 0  0      -2970
    2017 "Algeria"                21    30    51   25   14 0  0       -693
    1990 "American Samoa"          0     0     0    0    0 0  0          0
    1995 "American Samoa"          0     0     0    0    0 0  0          0
    2000 "American Samoa"          0     0     0    0    0 0  0          0
    2005 "American Samoa"          0     0     0    0    0 0  0          0
    2010 "American Samoa"          0     0     0    0    0 0  0          0
    2015 "American Samoa"          0     0     0    0    0 0  0          0
    2017 "American Samoa"          0     0     0    0    0 0  0          0
    1990 "Andorra"                 0     0     0    0    0 0  0          0
    1995 "Andorra"                 0     0     0    0    0 0  0          0
    2000 "Andorra"                 0     0     0    0    0 0  0          0
    2005 "Andorra"                 0     0     0    0    0 0  0          0
    2010 "Andorra"                 0     0     0    0    0 0  0          0
    2015 "Andorra"                 0     0     0    0    0 0  0          0
    2017 "Andorra"                 0     0     0    0    0 0  0          0
    1990 "Angola"                181   363   544   38   18 0  2     273000
    1995 "Angola"                430   423   853  284  205 7  1   10010000
    2000 "Angola"                410   678  1088   75   14 1  0   1.20e+07
    2005 "Angola"                534  1083  1617   68    6 0  3          0
    2010 "Angola"                  0     2     2    1    0 0  0          0
    2015 "Angola"                  7     4    11    2    0 0  0          0
    2017 "Angola"                  0     0     0    2    0 0  0          0
    1990 "Anguilla"                0     0     0    0    0 0  0          0
    1995 "Anguilla"                0     0     0    0    0 0  0          0
    2000 "Anguilla"                0     0     0    0    0 0  0          0
    2005 "Anguilla"                0     0     0    0    0 0  0          0
    2010 "Anguilla"                0     0     0    0    0 0  0          0
    2015 "Anguilla"                0     0     0    0    0 0  0          0
    2017 "Anguilla"                0     0     0    0    0 0  0          0
    1990 "Antigua and Barbuda"     0     0     0    0    0 0  0          0
    1995 "Antigua and Barbuda"     0     0     0    1    0 0  0          0
    2000 "Antigua and Barbuda"     0     0     0    0    0 0  0          0
    2005 "Antigua and Barbuda"     0     0     0    0    0 0  0          0
    2010 "Antigua and Barbuda"     0     0     0    0    0 0  0          0
    2015 "Antigua and Barbuda"     0     0     0    0    0 0  0          0
    2017 "Antigua and Barbuda"     0     0     0    0    0 0  0          0
    1990 "Argentina"              70    34   104  221  176 0  7    1862500
    1995 "Argentina"             498   120   618  114   85 0  5    1100000
    2000 "Argentina"              15     4    19   47   20 0  0          0
    2005 "Argentina"               1     0     1    3    3 0  1          0
    2010 "Argentina"               0     0     0    4    4 0  0       -198
    2015 "Argentina"               2     0     2   10    8 0  0       -297
    2017 "Argentina"               2     0     2    3    1 0  0          0
    1990 "Armenia"                27     6    33    7    6 0  0     810060
    1995 "Armenia"               170   103   273   76   29 0  0     100000
    2000 "Armenia"                21    12    33    6    4 0  0          0
    2005 "Armenia"                 0     1     1    4    2 0  0          0
    2010 "Armenia"                 0     1     1    2    1 0  0          0
    2015 "Armenia"                 1     0     1    1    0 0  0          0
    2017 "Armenia"                 2     6     8    4    1 0  0       -198
    1990 "Aruba"                   0     0     0    0    0 0  0          0
    1995 "Aruba"                   0     0     0    0    0 0  0          0
    2000 "Aruba"                   0     0     0    0    0 0  0          0
    2005 "Aruba"                   0     0     0    0    0 0  0          0
    2010 "Aruba"                   0     0     0    0    0 0  0          0
    2015 "Aruba"                   0     0     0    0    0 0  0          0
    2017 "Aruba"                   0     0     0    0    0 0  0          0
    1990 "Australia"              22     1    23    7    4 1  0      20000
    1995 "Australia"              12     4    16   17    6 0  1          0
    2000 "Australia"              26     2    28   20   10 0  0     112000
    2005 "Australia"               0     0     0    3    0 0  1          0
    2010 "Australia"               0     0     0    6    2 0  1      60000
    2015 "Australia"               7     4    11   10    0 0  2       -693
    2017 "Australia"               1     2     3   23    1 0 18       -982
    1990 "Austria"                52     7    59   15    9 0  0          0
    1995 "Austria"                10     2    12   28   17 0  1      12000
    2000 "Austria"                 7     6    13   18   10 0  0          0
    2005 "Austria"                 0     0     0    0    0 0  0          0
    2010 "Austria"                 9     1    10   12    0 0  1          0
    2015 "Austria"                 2     0     2    2    0 0  0        -99
    2017 "Austria"                 0     0     0    3    0 0  0     334992
    1990 "Azerbaijan"             27     6    33    7    6 0  0     810060
    1995 "Azerbaijan"            277   302   579   94   34 0  0     100000
    2000 "Azerbaijan"              0     3     3    5    2 0  0          0
    2005 "Azerbaijan"             10     1    11    6    2 0  0          0
    2010 "Azerbaijan"             15     6    21    5    3 0  2          0
    2015 "Azerbaijan"              1     0     1    3    1 0  2       7560
    2017 "Azerbaijan"              1     1     2    2    2 0  0          0
    1990 "Bahamas"                 0     0     0    0    0 0  0          0
    1995 "Bahamas"                 0     0     0    0    0 0  0          0
    end
    As you can see it's a panel database with data on victims of terrorism per countries per years. I would like to obtain two descriptive tables from that.
    • The first table would look like this:
    AttacksQuinq_or VictimsQuinq_or WoundedQuinq_or WeapBombQuinq_or TargViolPolQuinq_or TargReligQuinq_or PropvalueQuinq_or
    1990
    1995
    2000
    2005
    2010
    2015
    2017
    with the total number of attacks in 1990, the total number of victims in 1990 etc... Without any distinction of countries.
    • The second table would differenciate according to countries level of development (North and South countries). Basically my "North countries" are definied such as those having a GNI per capita above the High income threshold from the World Bank, while "South countries" are those below the medium to lower GNI per capita threshold. This would look like:
    AttacksQuinq_or VictimsQuinq_or WoundedQuinq_or WeapBombQuinq_or TargViolPolQuinq_or TargReligQuinq_or PropvalueQuinq_or
    NORTH 1990
    NORTH 1995
    NORTH 2000
    NORTH 2005
    NORTH 2010
    NORTH 2015
    NORTH 2017
    SOUTH 1990
    SOUTH 1995
    SOUTH 2000
    SOUTH 2005
    SOUTH 2010
    SOUTH 2015
    SOUTH 2017
    with data on north countries on the upper side and data on south countries below.


    ​​​​​​​
    2. Export these tables to Latex
    Then I would like to export these tables to latex. I know how to do it with "classic" descriptive stats (ie mean sd etc) but not with this kind of tables.




    Thank you very much for your future help,
    Have a good day,
    Killian

  • #2
    Getting your data into the right format if fairly easy using the -collapse- command. You should search for user contributed programs to find the best option to output to LaTex. One possibility is Roger Newson's -listtex- available on SSC (type: ssc describe listtex).

    Code:
    preserve
    collapse (sum) AttacksQuinq_or VictimsQuinq_or WoundedQuinq_or WeapBombQuinq_or TargViolPolQuinq_or TargReligQuinq_or PropvalueQuinq_or, by(year)
    list
    *listtex or something else to format for latex
    restore
    
    *generate a north_south variable that is 0 if north and 1 if south based on your criteria
    *creating a fake north_south var for these purposes
    gen north_south=0
    replace north_south=1 in 51/100
    lab define north_south 0 "North" 1 "South"
    lab val north_south north_south
    
    preserve
    collapse (sum) AttacksQuinq_or VictimsQuinq_or WoundedQuinq_or WeapBombQuinq_or TargViolPolQuinq_or TargReligQuinq_or PropvalueQuinq_or, by(north_south year )
    list
    *listtex or something else to format for latex
    restore
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      It works perfectly, thank you so much!

      Have a nice week,
      Killian

      Comment

      Working...
      X