Announcement

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

  • Descriptive statistics

    Goodmorning, I have an issue regarding some basic descriptive statistics. I have the following dataset
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int Year str36 Countryoforigin float tot_app
    2000 "Croatia"                                 10
    2000 "Pakistan"                                33
    2000 "Iraq"                                  5664
    2000 "Russian Federation"                     126
    2000 "Rwanda"                                  29
    2000 "Ghana"                                   15
    2000 "Armenia"                                 20
    2000 "Sierra Leone"                            74
    2000 "Iran (Islamic Rep. of)"                 205
    2000 "Burundi"                                  5
    2000 "Nigeria"                                 16
    2000 "Tunisia"                                 31
    2000 "Azerbaijan"                              10
    2000 "Ukraine"                                 10
    2000 "Sudan"                                   56
    2000 "Egypt"                                   15
    2000 "Unknown "                             13535
    2000 "Peru"                                     5
    2000 "Algeria"                                 15
    2000 "Rep. of Moldova"                         14
    2000 "Cote d'Ivoire"                            5
    2000 "Colombia"                                26
    2000 "Guinea"                                   5
    2000 "China"                                   19
    2000 "Libya"                                    5
    2000 "Dem. Rep. of the Congo"                  86
    2000 "Kazakhstan"                               5
    2000 "Bangladesh"                              55
    2000 "North Macedonia"                         58
    2000 "Liberia"                                 10
    2000 "Angola"                                  47
    2000 "Georgia"                                 29
    2000 "Uzbekistan"                               5
    2000 "Romania"                                114
    2000 "Palestinian"                             35
    2000 "Bosnia and Herzegovina"                  27
    2000 "Lebanon"                                 10
    2000 "Albania"                                135
    2000 "Syrian Arab Rep."                        49
    2000 "Somalia"                                 88
    2000 "Viet Nam"                                 5
    2000 "Turkey"                                3578
    2000 "Togo"                                    10
    2000 "Sri Lanka"                               56
    2000 "Cameroon"                                19
    2000 "Afghanistan"                            351
    2000 "Senegal"                                  5
    2000 "Eritrea"                                 18
    2000 "Guinea-Bissau"                           15
    2000 "Benin"                                    5
    2000 "Congo"                                  124
    2000 "Ethiopia"                                74
    2000 "Cuba"                                    15
    2001 "North Macedonia"                         79
    2001 "Gambia"                                  20
    2001 "Nigeria"                                115
    2001 "Colombia"                                86
    2001 "Bosnia and Herzegovina"                  72
    2001 "Lebanon"                                 31
    2001 "Unknown "                             13769
    2001 "Ethiopia"                               169
    2001 "Sri Lanka"                              168
    2001 "Congo"                                  212
    2001 "Turkey"                                6930
    2001 "Iran (Islamic Rep. of)"                 386
    2001 "Rwanda"                                  48
    2001 "Cameroon"                                46
    2001 "Eritrea"                                 65
    2001 "Russian Federation"                     299
    2001 "Romania"                                382
    2001 "Ukraine"                                 47
    2001 "Dem. Rep. of the Congo"                 197
    2001 "Angola"                                  73
    2001 "Afghanistan"                            805
    2001 "Sudan"                                   94
    2001 "Algeria"                                 42
    2001 "Palestinian"                             62
    2001 "Rep. of Moldova"                         52
    2001 "Pakistan"                                93
    2001 "Togo"                                    37
    2001 "Somalia"                                180
    2001 "Bangladesh"                             116
    2001 "Albania"                                285
    2001 "Sierra Leone"                           238
    2001 "Serbia and Kosovo: S/RES/1244 (1999)"  2430
    2001 "Iraq"                                 10246
    2001 "Tunisia"                                 57
    2002 "Cameroon"                                80
    2002 "Pakistan"                               179
    2002 "Somalia"                                258
    2002 "Cote d'Ivoire"                           10
    2002 "Sierra Leone"                           362
    2002 "Colombia"                               180
    2002 "Georgia"                                 47
    2002 "Bosnia and Herzegovina"                 122
    2002 "Serbia and Kosovo: S/RES/1244 (1999)"  3637
    2002 "Afghanistan"                           1215
    2002 "Unknown "                             14086
    2002 "Syrian Arab Rep."                       107
    2002 "Russian Federation"                     407
    end
    and I want to create a table which display for each Countryoforigin the value af the variable tot_app only for one year (f.e. 2002). I would like the values to be rapresented from the largest to the smallest. Is it possible?
    Thanks for your attention

  • #2
    You can use -tabsort- command written by Nick Cox to accomplish that.
    Code:
    ssc install tab_chi
    tabsort Countryoforigin if Year==2002, summ(tot_app) sort(mean)
    
    
    Countryofor |         Summary of tot_app
           igin |        Mean   Std. Dev.       Freq.
    ------------+------------------------------------
       Unknown  |       14086           0           1
      Serbia an |        3637           0           1
      Afghanist |        1215           0           1
      Russian F |         407           0           1
      Sierra Le |         362           0           1
        Somalia |         258           0           1
       Colombia |         180           0           1
       Pakistan |         179           0           1
      Bosnia an |         122           0           1
      Syrian Ar |         107           0           1
       Cameroon |          80           0           1
        Georgia |          47           0           1
      Cote d'Iv |          10           0           1
    ------------+------------------------------------
          Total |   1591.5385   3880.0043          13

    Comment


    • #3
      Perfect, Thanks a lot

      Comment


      • #4
        Thanks for the mention but I would not use tabsort here at all.

        Code:
        gsort Year -tot_app
        
        list Country tot_app if Year == 2002, noobs sep(0)

        Comment


        • #5
          Certainly we can use gsort here, and I should have suggested it as prior choice. Given that tabsort reports mean and sd, it is in the strict sense not suitable for Enrico's task in itself.

          Comment


          • #6
            Thank you, it's very useful to know another way.
            I've alreay posted a question asking how create a graph using only the highest values for the variable but I didn't received a feedback. Can you help me also about that? For example how can I create I bar chart that displays only ten countries with the highest value for tot_app in year 2002? I feel bad to ask so many thinghs but I didn't find anything about that.

            Comment


            • #7
              Sorry I didn't notice that you already answered to my question in the post. Thank you very much.

              Comment

              Working...
              X