Announcement

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

  • Help summing data for men and women

    Hi,
    I have data on the number of people of each age in each local authority. The problem at the moment is my data is separated by gender, but I would like totals of males and females of each age in each local authority at each time. I just want to sum the value for female+male when everything else is the same.

    Thank You

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str36 name str9 code str7 gender int year float age long(allages noofpeople) float agecat
    "Shepway"                   "E07000112" "Female" 2015 0   55620   499 10
    "Rossendale"                "E07000125" "Female" 2013 0   34946   407 10
    "Hertsmere"                 "E07000098" "Female" 2016 0   53812   656 10
    "Kettering"                 "E07000153" "Female" 2015 0   49607   602 10
    "Eastbourne"                "E07000061" "Female" 2015 0   52873   588 10
    "Carlisle"                  "E07000028" "Female" 2015 0   55330   558 10
    "Epsom and Ewell"           "E07000208" "Male"   2013 0   37224   475 10
    "West Sussex"               "E10000032" "Female" 2016 0  435167  4438 10
    "Derby"                     "E06000015" "Male"   2015 0  125664  1802 10
    "Wealden"                   "E07000065" "Male"   2015 0   75561   711 10
    "Cheltenham"                "E07000078" "Female" 2012 0   59204   689 10
    "Barrow-in-Furness"         "E07000027" "Male"   2015 0   33472   369 10
    "Nottingham"                "E06000018" "Male"   2016 0  164371  2253 10
    "Islington"                 "E09000019" "Female" 2014 0  111195  1365 10
    "City of London"            "E09000001" "Female" 2014 0    2712    29 10
    "Sheffield"                 "E08000019" "Male"   2016 0  285353  3376 10
    "Exeter"                    "E07000041" "Male"   2014 0   60520   740 10
    "Southampton"               "E06000045" "Male"   2016 0  127762  1697 10
    "Rugby"                     "E07000220" "Male"   2012 0   50339   692 10
    "Northampton"               "E07000154" "Female" 2016 0  113200  1625 10
    "East Hertfordshire"        "E07000242" "Female" 2012 0   70842   821 10
    "North Norfolk"             "E07000147" "Male"   2016 0   50372   394 10
    "Surrey"                    "E10000030" "Female" 2012 0  583530  7026 10
    "Daventry"                  "E07000151" "Male"   2016 0   40485   423 10
    "Epsom and Ewell"           "E07000208" "Female" 2015 0   40516   466 10
    "Bolsover"                  "E07000033" "Male"   2016 0   38625   429 10
    "Taunton Deane"             "E07000190" "Female" 2016 0   59615   601 10
    "Mansfield"                 "E07000174" "Female" 2013 0   53572   649 10
    "Bexley"                    "E09000004" "Male"   2016 0  118293  1634 10
    "Dover"                     "E07000108" "Male"   2016 0   56381   580 10
    "Sedgemoor"                 "E07000188" "Male"   2016 0   59599   706 10
    "Herefordshire, County of"  "E06000019" "Female" 2013 0   94386   927 10
    "Havering"                  "E09000016" "Male"   2014 0  118199  1616 10
    "Bromley"                   "E09000006" "Male"   2015 0  156274  2096 10
    "North Tyneside"            "E08000022" "Female" 2013 0  104565  1105 10
    "Broxbourne"                "E07000095" "Female" 2012 0   48838   630 10
    "North Somerset"            "E06000024" "Male"   2012 0   99451  1190 10
    "Rossendale"                "E07000125" "Female" 2014 0   35225   416 10
    "Harrow"                    "E09000015" "Female" 2016 0  124736  1799 10
    "Corby"                     "E07000150" "Female" 2013 0   32753   455 10
    "Torridge"                  "E07000046" "Male"   2015 0   32438   298 10
    "Richmond upon Thames"      "E09000027" "Male"   2013 0   92871  1453 10
    "Northumberland"            "E06000057" "Male"   2012 0  154470  1630 10
    "Rushcliffe"                "E07000176" "Male"   2015 0   56368   547 10
    "Tendring"                  "E07000076" "Female" 2013 0   72382   642 10
    "Wycombe"                   "E07000007" "Male"   2012 0   85087  1163 10
    "Wyre Forest"               "E07000239" "Female" 2013 0   49891   534 10
    "Northumberland"            "E06000057" "Male"   2016 0  154971  1471 10
    "Gloucestershire"           "E10000013" "Male"   2012 0  295517  3578 10
    "South Somerset"            "E07000189" "Male"   2015 0   81388   856 10
    "Gedling"                   "E07000173" "Male"   2013 0   56125   622 10
    "Crawley"                   "E07000226" "Female" 2016 0   55788   790 10
    "Wyre"                      "E07000128" "Male"   2014 0   52846   511 10
    "Colchester"                "E07000071" "Female" 2012 0   89152  1116 10
    "Lincolnshire"              "E10000019" "Male"   2013 0  353402  3865 10
    "Derbyshire Dales"          "E07000035" "Male"   2013 0   35151   264 10
    "Brentwood"                 "E07000068" "Male"   2014 0   36844   428 10
    "Chorley"                   "E07000118" "Male"   2015 0   56591   610 10
    "Cheshire West and Chester" "E06000050" "Male"   2015 0  162767  1855 10
    "High Peak"                 "E07000037" "Female" 2013 0   46275   466 10
    "Dartford"                  "E07000107" "Female" 2013 0   50809   731 10
    "West Lancashire"           "E07000127" "Male"   2015 0   54623   560 10
    "Herefordshire, County of"  "E06000019" "Female" 2016 0   95645   832 10
    "Forest Heath"              "E07000201" "Female" 2014 0   30975   478 10
    "Slough"                    "E06000039" "Female" 2014 0   72095  1294 10
    "Isle of Wight"             "E06000046" "Female" 2013 0   70868   618 10
    "Ryedale"                   "E07000167" "Male"   2012 0   25626   226 10
    "Cannock Chase"             "E07000192" "Female" 2012 0   49582   531 10
    "Cheshire East"             "E06000049" "Female" 2012 0  189804  1991 10
    "East Hertfordshire"        "E07000242" "Female" 2015 0   73613   785 10
    "Milton Keynes"             "E06000042" "Male"   2012 0  125061  2089 10
    "South Tyneside"            "E08000023" "Female" 2013 0   76738   813 10
    "Winchester"                "E07000094" "Female" 2013 0   61224   592 10
    "East Northamptonshire"     "E07000152" "Male"   2016 0   45226   488 10
    "Barnsley"                  "E08000016" "Female" 2013 0  119713  1444 10
    "Stevenage"                 "E07000243" "Female" 2012 0   43066   628 10
    "Wellingborough"            "E07000156" "Female" 2015 0   39476   447 10
    "Lancashire"                "E10000017" "Male"   2015 0  586252  6793 10
    "Tameside"                  "E08000008" "Male"   2016 0  109506  1474 10
    "Rochdale"                  "E08000005" "Male"   2013 0  103940  1573 10
    "Herefordshire, County of"  "E06000019" "Male"   2016 0   93887   916 10
    "NORTH WEST"                "E12000002" "Female" 2015 0 3640124 41715 10
    "North Devon"               "E07000043" "Male"   2015 0   46104   448 10
    "Rother"                    "E07000064" "Female" 2012 0   47680   342 10
    "Bromsgrove"                "E07000234" "Male"   2015 0   47331   477 10
    "St Albans"                 "E07000240" "Male"   2014 0   71081   931 10
    "Darlington"                "E06000005" "Male"   2016 0   51804   619 10
    "NORTH EAST"                "E12000001" "Male"   2013 0 1278374 15323 10
    "Bolsover"                  "E07000033" "Male"   2012 0   37676   431 10
    "South Bucks"               "E07000006" "Male"   2013 0   32960   389 10
    "Northamptonshire"          "E10000021" "Female" 2013 0  357859  4479 10
    "Warwick"                   "E07000222" "Male"   2012 0   69158   870 10
    "Welwyn Hatfield"           "E07000241" "Male"   2013 0   55876   697 10
    "Spelthorne"                "E07000213" "Female" 2012 0   48965   575 10
    "Southend-on-Sea"           "E06000033" "Female" 2015 0   91408  1106 10
    "Bracknell Forest"          "E06000036" "Female" 2012 0   57884   790 10
    "Torridge"                  "E07000046" "Male"   2016 0   32837   359 10
    "Worthing"                  "E07000229" "Female" 2013 0   55209   555 10
    "Charnwood"                 "E07000130" "Female" 2013 0   84782   882 10
    "Reigate and Banstead"      "E07000211" "Male"   2012 0   68385   990 10
    end

  • #2
    Originally posted by Darcy Hill View Post
    I just want to sum the value for female+male when everything else is the same.
    Either tabstat or collapse will get you what you want. You'd select one or the other, depending how you want the results returned.
    Code:
    help tabstat
    help collapse
    for further information.

    Comment


    • #3
      Hi Joseph,
      I am aware I want to use the collapse command, what I am actually not sure how to do is the rest of the command? I am new to Stata and would be grateful if you could help me sum these genders.
      Last edited by Darcy Hill; 05 Mar 2019, 03:00.

      Comment


      • #4
        If each local authority is represented by observations for Male and Female in each age category year then

        Code:
        collapse (sum) noofpeople , by(name agecat year)
        may be what you want.

        After 51 posts, on each of which you are reminded to read the Statalist FAQ, you should now be spelling Stata correctly! https://www.statalist.org/forums/help#spelling
        Last edited by Nick Cox; 05 Mar 2019, 02:55.

        Comment


        • #5
          That's great! Thank you Nick. I edited my last post

          Comment


          • #6
            Hard to see how this question differs from https://www.statalist.org/forums/for...ear-and-gender

            Comment


            • #7
              Hi Nick, I was trying to form categories in the other question, and in this just merging genders, but yes they are similiar! Happy to have got answers to both of them.

              Comment

              Working...
              X