I have the following time series of the US population by city and state in 2010-2017.
They have the following shape:
city state y2010 y2011 y2012
"Abbot" "Maine" "714" 706 700
I need to transform these into the following panel:
city state population year
"Abbot" "Maine" "714" 2010
"Abbot" "Maine" 706 2011
"Abbot" "Maine" 700 2012
"Abbot" "Maine" 701 2013
"Abbot" "Maine" 702 2014
"Abbot" "Maine" 709 2015
"Abbot" "Maine" 703 2016
"Abbot" "Maine" 703 2017
"Acton" "Maine" 2447 2010
"Acton" "Maine" 2481 2011
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str57 name str20 state str8 y2010 long(y2011 y2012 y2013 y2014 y2015 y2016 y2017) "Abbot" "Maine" "714" 706 702 698 692 684 682 678 "Abernathy" "Texas" "2805" 2833 2822 2798 2738 2724 2741 2735 "Abilene" "Texas" "117063" 118762 119853 119797 120648 121707 121883 122186 "Abington" "Massachusetts" "15985" 16076 16095 16164 16230 16266 16335 16417 "Abrams" "Wisconsin" "1856" 1859 1850 1852 1858 1860 1864 1871 "Acadia Parish" "Louisiana" "61773" 61865 61997 62299 62667 62679 62786 62559 "Ackerly" "Texas" "220" 219 219 225 228 230 229 228 "Ackley" "Iowa" "1589" 1575 1573 1560 1558 1546 1537 1520 "Ackley" "Wisconsin" "524" 520 517 512 509 503 505 508 "Acton" "Maine" "2447" 2481 2497 2513 2539 2553 2567 2588 "Acton" "Massachusetts" "21924" 22274 22676 22928 23256 23488 23607 23716 "Acushnet" "Massachusetts" "10303" 10304 10322 10346 10399 10453 10483 10520 "Acworth" "New Hampshire" "891" 895 896 891 891 891 888 884 "Adair" "Iowa" "781" 767 754 746 743 719 699 702 "Adams" "Massachusetts" "8485" 8426 8422 8381 8318 8238 8174 8120
0 Response to Transform time series into panel data
Post a Comment