I have the following data for years 2012-2016 for males and females in this dataset. The v6, v7, v8 go all the way to 100 and tell us the number of people of each age. I want to add the values for each local authority by gender, and then total the numbers into age bands 1-10, 11-20 ect... so that I end up with the total number of people in each age band by local authority level.
Any help is greatly appreciated!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year str7 gender str9 code str36 name str7(v6 v7 v8) 2012 "Female " "E92000001" "ENGLAND" "339,662" "333,659" "329,489" 2012 "Female " "E12000001" "NORTH EAST" "14,909" "14,996" "14,791" 2012 "Female " "E06000047" "County Durham" "2,755" "2,913" "2,877" 2012 "Female " "E06000005" "Darlington" "661" "629" "651" 2012 "Female " "E06000001" "Hartlepool" "557" "559" "575" 2012 "Female " "E06000002" "Middlesbrough" "983" "1,039" "925" 2012 "Female " "E06000057" "Northumberland" "1,507" "1,520" "1,569" 2012 "Female " "E06000003" "Redcar and Cleveland" "755" "798" "750" 2012 "Female " "E06000004" "Stockton-on-Tees" "1,245" "1,223" "1,225" 2012 "Female " "E11000007" "Tyne and Wear (Met County)" "6,446" "6,315" "6,219" 2012 "Female " "E08000037" "Gateshead" "1,134" "1,206" "1,117" 2012 "Female " "E08000021" "Newcastle upon Tyne" "1,657" "1,695" "1,663" 2012 "Female " "E08000022" "North Tyneside" "1,172" "1,149" "1,144" 2012 "Female " "E08000023" "South Tyneside" "846" "790" "807" 2012 "Female " "E08000024" "Sunderland" "1,637" "1,475" "1,488" 2012 "Female " "E12000002" "NORTH WEST" "43,919" "43,373" "42,508" 2012 "Female " "E06000008" "Blackburn with Darwen" "1,170" "1,046" "1,094" 2012 "Female " "E06000009" "Blackpool" "932" "830" "810" 2012 "Female " "E06000049" "Cheshire East" "1,991" "2,091" "1,858" 2012 "Female " "E06000050" "Cheshire West and Chester" "1,814" "1,795" "1,800" 2012 "Female " "E06000006" "Halton" "762" "807" "910" 2012 "Female " "E06000007" "Warrington" "1,195" "1,294" "1,166" 2012 "Female " "E10000006" "Cumbria" "2,527" "2,524" "2,453" 2012 "Female " "E07000026" "Allerdale" "480" "523" "510" 2012 "Female " "E07000027" "Barrow-in-Furness" "386" "366" "330" 2012 "Female " "E07000028" "Carlisle" "656" "627" "586" 2012 "Female " "E07000029" "Copeland" "373" "353" "366" 2012 "Female " "E07000030" "Eden" "187" "222" "237" 2012 "Female " "E07000031" "South Lakeland" "445" "433" "424" 2012 "Female " "E11000001" "Greater Manchester (Met County)" "18,691" "18,381" "17,932" 2012 "Female " "E08000001" "Bolton" "2,003" "1,957" "1,920" 2012 "Female " "E08000002" "Bury" "1,244" "1,277" "1,167" 2012 "Female " "E08000003" "Manchester" "4,081" "3,705" "3,625" 2012 "Female " "E08000004" "Oldham" "1,648" "1,642" "1,650" 2012 "Female " "E08000005" "Rochdale" "1,461" "1,484" "1,429" 2012 "Female " "E08000006" "Salford" "1,709" "1,750" "1,579" 2012 "Female " "E08000007" "Stockport" "1,723" "1,710" "1,688" 2012 "Female " "E08000008" "Tameside" "1,518" "1,485" "1,498" 2012 "Female " "E08000009" "Trafford" "1,382" "1,472" "1,469" 2012 "Female " "E08000010" "Wigan" "1,922" "1,899" "1,907" 2012 "Female " "E10000017" "Lancashire" "6,529" "6,719" "6,738" 2012 "Female " "E07000117" "Burnley" "602" "551" "597" 2012 "Female " "E07000118" "Chorley" "612" "649" "634" 2012 "Female " "E07000119" "Fylde" "294" "414" "370" 2012 "Female " "E07000120" "Hyndburn" "539" "517" "518" 2012 "Female " "E07000121" "Lancaster" "775" "779" "688" 2012 "Female " "E07000122" "Pendle" "616" "632" "623" 2012 "Female " "E07000123" "Preston" "876" "888" "952" 2012 "Female " "E07000124" "Ribble Valley" "225" "246" "288" 2012 "Female " "E07000125" "Rossendale" "428" "435" "427" 2012 "Female " "E07000126" "South Ribble" "568" "626" "602" 2012 "Female " "E07000127" "West Lancashire" "544" "534" "573" 2012 "Female " "E07000128" "Wyre" "450" "448" "466" 2012 "Female " "E11000002" "Merseyside (Met County)" "8,308" "7,886" "7,747" 2012 "Female " "E08000011" "Knowsley" "922" "954" "867" 2012 "Female " "E08000012" "Liverpool" "3,009" "2,641" "2,536" 2012 "Female " "E08000014" "Sefton" "1,386" "1,439" "1,441" 2012 "Female " "E08000013" "St. Helens" "1,092" "1,021" "1,070" 2012 "Female " "E08000015" "Wirral" "1,899" "1,831" "1,833" 2012 "Female " "E12000003" "YORKSHIRE AND THE HUMBER" "33,314" "32,361" "32,652" 2012 "Female " "E06000011" "East Riding of Yorkshire" "1,463" "1,556" "1,649" 2012 "Female " "E06000010" "Kingston upon Hull, City of" "1,883" "1,734" "1,713" 2012 "Female " "E06000012" "North East Lincolnshire" "1,054" "960" "1,048" 2012 "Female " "E06000013" "North Lincolnshire" "944" "1,019" "975" 2012 "Female " "E06000014" "York" "1,051" "1,031" "1,071" 2012 "Female " "E10000023" "North Yorkshire" "3,049" "3,023" "3,048" 2012 "Female " "E07000163" "Craven" "267" "240" "255" 2012 "Female " "E07000164" "Hambleton" "452" "423" "437" 2012 "Female " "E07000165" "Harrogate" "797" "843" "848" 2012 "Female " "E07000166" "Richmondshire" "302" "310" "258" 2012 "Female " "E07000167" "Ryedale" "201" "241" "249" 2012 "Female " "E07000168" "Scarborough" "566" "513" "525" 2012 "Female " "E07000169" "Selby" "464" "453" "476" 2012 "Female " "E11000003" "South Yorkshire (Met County)" "8,316" "8,009" "8,237" 2012 "Female " "E08000016" "Barnsley" "1,480" "1,374" "1,405" 2012 "Female " "E08000017" "Doncaster" "1,832" "1,872" "1,906" 2012 "Female " "E08000018" "Rotherham" "1,548" "1,522" "1,567" 2012 "Female " "E08000019" "Sheffield" "3,456" "3,241" "3,359" 2012 "Female " "E11000006" "West Yorkshire (Met County)" "15,554" "15,029" "14,911" 2012 "Female " "E08000032" "Bradford" "4,140" "3,994" "4,036" 2012 "Female " "E08000033" "Calderdale" "1,290" "1,259" "1,304" 2012 "Female " "E08000034" "Kirklees" "2,942" "2,926" "2,746" 2012 "Female " "E08000035" "Leeds" "5,107" "4,896" "4,898" 2012 "Female " "E08000036" "Wakefield" "2,075" "1,954" "1,927" 2012 "Female " "E12000004" "EAST MIDLANDS" "27,265" "27,133" "26,777" 2012 "Female " "E06000015" "Derby" "1,922" "1,798" "1,715" 2012 "Female " "E06000016" "Leicester" "2,621" "2,504" "2,390" 2012 "Female " "E06000018" "Nottingham" "2,140" "1,927" "1,950" 2012 "Female " "E06000017" "Rutland" "152" "171" "191" 2012 "Female " "E10000007" "Derbyshire" "4,096" "4,154" "4,081" 2012 "Female " "E07000032" "Amber Valley" "607" "650" "628" 2012 "Female " "E07000033" "Bolsover" "444" "469" "364" 2012 "Female " "E07000034" "Chesterfield" "598" "577" "568" 2012 "Female " "E07000035" "Derbyshire Dales" "312" "285" "303" 2012 "Female " "E07000036" "Erewash" "663" "646" "666" 2012 "Female " "E07000037" "High Peak" "488" "502" "472" 2012 "Female " "E07000038" "North East Derbyshire" "465" "471" "491" 2012 "Female " "E07000039" "South Derbyshire" "519" "554" "589" 2012 "Female " "E10000018" "Leicestershire" "3,485" "3,637" "3,671" 2012 "Female " "E07000129" "Blaby" "487" "544" "548" end
0 Response to Grouping Data by year and Gender
Post a Comment