I am trying to reshape this data, so that I have Country and Year both as a Columns. I imported this data from an excel spreadsheet.
Here is my Code. I specified string, because based on my statalist search that seemed the easiest way to address the previous error
Code:
reshape long B C D E F G H I J K L M N O P, i(CountryName) j(Year, string)
variable B already defined
r(110);
I also tried this code, but god another error, and tried to redress with the string specification
Code:
. reshape long B C D E F G H I J K L M N O P, i(CountryName) j(Year)
variable Year contains all missing values
r(498);
Note, I imported this from excel, where B C F E etc were years, but stata converted them to letters. I am not sure if that is relevant.
Here is the dataex extract of my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str24 CountryName long(B C D E F G H I J K L M N O P) float id "Afghanistan" 26433058 27100542 27722281 28394806 29185511 30117411 31161378 32269592 33370804 34413603 35383028 36296111 37171922 38041757 38928341 1 "Albania" 2992547 2970017 2947314 2927519 2913021 2905195 2900401 2895092 2889104 2880703 2876101 2873457 2866376 2854191 2837743 2 "Algeria" 33641007 34166976 34730604 35333882 35977451 36661438 37383899 38140135 38923688 39728020 40551398 41389174 42228415 43053054 43851043 3 "Angola" 20149905 20905360 21695636 22514275 23356247 24220660 25107925 26015786 26941773 27884380 28842482 29816769 30809787 31825299 32866268 4 "Argentina" 39289876 39684303 40080159 40482786 40788453 41261490 41733271 42202935 42669500 43131966 43590368 44044811 44494502 44938712 45376763 5 "Armenia" 2958301 2932615 2907615 2888094 2877314 2876536 2884239 2897593 2912403 2925559 2936147 2944789 2951741 2957728 2963234 6 "Australia" 20697900 20827600 21249200 21691700 22031750 22340024 22733465 23128129 23475686 23815995 24190907 24601860 24982688 25365745 25687041 7 "Azerbaijan" 8484550 8581300 8763400 8947243 9054332 9173082 9295784 9416801 9535079 9649341 9757812 9854033 9939771 10024283 10093121 8 "Bahrain" 958423 1035924 1114645 1185075 1240864 1278153 1299942 1315029 1336073 1371853 1425793 1494077 1569440 1641164 1701583 9 "Bangladesh" 140921154 142660381 144304164 145924795 147575433 149273134 151005733 152761413 154517385 156256287 157977151 159685421 161376713 163046173 164689383 10 "Barbados" 277475 278701 279946 281107 282131 282987 283698 284294 284825 285327 285798 286229 286640 287021 287371 11 "Belarus" 9604924 9560953 9527985 9504583 9483836 9461643 9446836 9443211 9448515 9461076 9469379 9458989 9438785 9419758 9379952 12 "Belize" 291338 299031 306822 314655 322465 330236 338001 345707 353366 360926 368399 375775 383071 390351 397621 13 "Benin" 8216893 8454790 8696915 8944713 9199254 9460829 9729254 10004594 10286839 10575962 10872072 11175192 11485035 11801151 12123198 14 "Bhutan" 657404 664873 671611 678329 685502 693297 701582 710235 719053 727885 736706 745563 754396 763094 771612 15 "Bolivia" 9395449 9558438 9721457 9884790 10048597 10212951 10377677 10542375 10706517 10869732 11031822 11192853 11353140 11513102 11673029 16 "Bosnia and Herzegovina" 3765422 3762791 3754261 3735945 3705478 3661173 3604972 3542598 3482106 3429362 3386263 3351534 3323929 3300998 3280815 17 "Botswana" 1835911 1875458 1915636 1953495 1987106 2015406 2039551 2062551 2088619 2120716 2159925 2205076 2254067 2303703 2351625 18 "Brazil" 188167353 190130445 192030362 193886505 195713637 197514541 199287292 201035904 202763744 204471759 206163056 207833825 209469320 211049519 212559409 19 "Brunei Darussalam" 370262 374967 379418 383902 388634 393687 398997 404414 409778 414914 419791 424481 428960 433296 437483 20 "Burkina Faso" 13829173 14252029 14689725 15141098 15605211 16081915 16571252 17072791 17586029 18110616 18646350 19193236 19751466 20321383 20903278 21 "Burundi" 7607850 7862226 8126104 8397661 8675606 8958406 9245992 9540302 9844301 10160034 10488002 10827010 11175379 11530577 11890781 22 "Cape Verde" 469171 475067 480846 486667 492644 498858 505241 511740 518276 524740 531140 537499 543764 549936 555988 23 "Cambodia" 13477705 13679953 13883835 14093605 14312205 14541421 14780454 15026330 15274506 15521435 15766290 16009413 16249795 16486542 16718971 24 "Cameroon" 18223677 18730283 19252674 19789922 20341236 20906392 21485267 22077300 22681853 23298376 23926549 24566070 25216261 25876387 26545864 25 "Canada" 32571174 32889025 33247118 33628895 34004889 34339328 34714222 35082954 35437435 35702908 36109487 36545295 37065178 37593384 38005238 26 "Central African Republic" 4118075 4198004 4273368 4337623 4386765 4418639 4436411 4447945 4464171 4493171 4537683 4596023 4666375 4745179 4829764 27 "Chad" 10457122 10818031 11183589 11560142 11952134 12360986 12784748 13220433 13663562 14110971 14561658 15016761 15477727 15946882 16425859 28 "Chile" 16354507 16530201 16708255 16886184 17062531 17233584 17400359 17571511 17758969 17969356 18209072 18470435 18729166 18952035 19116209 29 "China" 1311020000 1317885000 1324655000 1331260000 1337705000 1345035000 1354190000 1363240000 1371860000 1379860000 1387790000 1396215000 1402760000 1407745000 1410929362 30 "Colombia" 43200901 43737512 44254972 44750054 45222699 45662747 46075721 46495492 46967706 47520667 48175048 48909844 49661056 50339443 50882884 31 "Comoros" 626427 641624 657227 673251 689696 706578 723865 741511 759390 777435 795597 813890 832322 850891 869595 32 "Congo Republic" 56578046 58453687 60411195 62448572 64563853 66755151 69020749 71358804 73767445 76244532 78789130 81398765 84068092 86790568 89561404 33 "Congo, Rep." 3745143 3876123 4011487 4145400 4273738 4394842 4510197 4622757 4736965 4856093 4980996 5110701 5244363 5380504 5518092 34 "Costa Rica" 4345421 4404626 4463123 4520739 4577371 4633086 4688003 4742111 4795390 4847805 4899336 4949955 4999443 5047561 5094114 35 "Cote d'Ivoire" 18754914 19171250 19605568 20059147 20532944 21028652 21547188 22087506 22647672 23226148 23822726 24437475 25069226 25716554 26378275 36 "Cuba" 11261241 11251117 11236975 11226711 11225833 11236671 11257112 11282722 11306909 11324777 11335108 11339255 11338146 11333484 11326616 37 "Djibouti" 794554 805456 816361 827820 840194 853671 868136 883296 898707 913998 929117 944100 958923 973557 988002 38 "Dominica" 70718 70797 70829 70848 70877 70912 70954 71019 71091 71175 71307 71460 71626 71808 71991 39 "Dominican Republic" 9218681 9338856 9458079 9576736 9695117 9813219 9930916 10048226 10165182 10281675 10397738 10513111 10627147 10738957 10847904 40 "Ecuador" 14059379 14296554 14535740 14774412 15011114 15243885 15474099 15707473 15951832 16212022 16491116 16785356 17084359 17373657 17643060 41 "Egypt" 76873670 78232124 79636081 81134789 82761244 84529251 86422240 88404652 90424668 92442549 94447071 96442590 98423602 100388076 102334403 42 "El Salvador" 6079395 6105810 6131767 6157678 6183877 6210567 6237922 6266076 6295124 6325121 6356137 6388124 6420740 6453550 6486201 43 "Equatorial Guinea" 784494 821686 860839 901589 943640 986861 1031191 1076412 1122273 1168575 1215181 1262008 1308966 1355982 1402985 44 "Eritrea" 2918209 2996540 3062782 3119920 3170437 3213969 3213969 3213969 3213969 3213969 3213969 3213969 3213969 3213969 3213969 45 "Estonia" 1346810 1340680 1337090 1334515 1331475 1327439 1322696 1317997 1314545 1315407 1315790 1317384 1321977 1326898 1331057 46 "Eswatini" 1036095 1042651 1049948 1057462 1064841 1072029 1079285 1086843 1095022 1104038 1113994 1124808 1136274 1148133 1160164 47 "Ethiopia" 78489205 80674343 82916236 85233923 87639962 90139928 92726982 95385793 98094264 100835453 103603461 106399926 109224410 112078727 114963583 48 "Fiji" 827869 836185 845356 853636 859816 863451 865065 865602 866447 868632 872406 877460 883490 889955 896444 49 "Gabon" 1430144 1472565 1518538 1568925 1624146 1684629 1749677 1817070 1883801 1947690 2007882 2064812 2119275 2172578 2225728 50 "Gambia" 1591444 1639846 1689288 1740277 1793199 1848142 1905020 1963708 2024037 2085860 2149134 2213900 2280092 2347696 2416664 51 "Georgia" 3880347 3860158 3848449 3814419 3786695 3756441 3728874 3717668 3719414 3725276 3727505 3728004 3726549 3720161 3714000 52 "Ghana" 22379057 22963946 23563832 24170943 24779614 25387713 25996454 26607641 27224480 27849203 28481947 29121464 29767108 30417858 31072945 53 "Grenada" 104938 105183 105457 105787 106227 106786 107452 108172 108900 109603 110263 110874 111449 112002 112519 54 "Guatemala" 13213330 13477017 13739299 14000190 14259687 14521515 14781942 15043981 15306316 15567419 15827690 16087418 16346950 16604026 16858333 55 "Guinea" 9307421 9518159 9738796 9964470 10192168 10420459 10652032 10892821 11150970 11432096 11738434 12067516 12414292 12771246 13132792 56 "Guinea Bissau" 1377582 1411545 1446936 1483920 1522603 1562996 1604981 1648259 1692433 1737207 1782434 1828146 1874304 1920917 1967998 57 "Guyana" 746335 746477 746815 747718 749430 752029 755388 759281 763371 767433 771363 775218 779007 782775 786559 58 "Haiti" 9344784 9495336 9646570 9798046 9949318 10100320 10250922 10400672 10549007 10695540 10839976 10982367 11123183 11263079 11402533 59 "Honduras" 7634295 7808520 7980955 8150780 8317467 8480670 8640692 8798524 8955579 9112904 9270794 9429016 9587523 9746115 9904608 60 "India" 1165486291 1183209471 1200669762 1217726217 1234281163 1250287939 1265780243 1280842119 1295600768 1310152392 1324517250 1338676779 1352642283 1366417756 1380004385 61 "Indonesia" 229318262 232374239 235469755 238620554 241834226 245115988 248451714 251805314 255128076 258383257 261556386 264650969 267670549 270625567 273523621 62 "Iran" 70554756 71336476 72120608 72924833 73762519 74634959 75539881 76481963 77465769 78492208 79563991 80673888 81800204 82913893 83992953 63 "Iraq" 27448124 27911242 28385739 28973157 29741977 30725305 31890012 33157061 34411949 35572269 36610632 37552789 38433604 39309789 40222503 64 "Israel" 7053700 7180100 7308800 7485600 7623600 7765800 7910500 8059500 8215700 8380100 8546000 8713300 8882800 9054000 9216900 65 "Jamaica" 2754414 2768229 2781869 2795839 2810464 2825932 2842128 2858710 2875137 2891024 2906242 2920848 2934853 2948277 2961161 66 "Japan" 127854000 128001000 128063000 128047000 128070000 127833000 127629000 127445000 127276000 127141000 126994511 126785797 126529100 126264931 125836021 67 "Jordan" 5991547 6255290 6556473 6893258 7261541 7662858 8089963 8518992 8918822 9266573 9554286 9785840 9965322 10101697 10203140 68 "Kazakhstan" 15308085 15484192 15776938 16092822 16321872 16557202 16792090 17035551 17288285 17542806 17794055 18037776 18276452 18513673 18754440 69 "Kenya" 37649039 38705934 39791984 40901798 42030684 43178270 44343469 45519986 46700063 47878339 49051531 50221146 51392570 52573967 53771300 70 "North Korea" 24054866 24188330 24310143 24428340 24548840 24673392 24800638 24929500 25057793 25183832 25307665 25429816 25549606 25666158 25778815 71 "South Korea" 48438292 48683638 49054708 49307835 49554112 49936638 50199853 50428893 50746659 51014947 51217803 51361911 51606633 51709098 51780579 72 "Kosovo" 1719536 1733404 1747383 1761474 1775680 1791000 1807106 1818117 1812771 1788196 1777557 1791003 1797085 1788878 1775378 73 "Kuwait" 2373661 2504026 2656010 2821041 2991884 3168054 3348852 3526382 3690939 3835588 3956862 4056102 4137314 4207077 4270563 74 "Kyrgyz Republic" 5218400 5268400 5318700 5383300 5447900 5514600 5607200 5719600 5835500 5956900 6079500 6198200 6322800 6456200 6591600 75 "Laos" 5846075 5944950 6046630 6148621 6249168 6347564 6444527 6541302 6639763 6741160 6845848 6953031 7061498 7169456 7275556 76 "Lebanon" 4759760 4767347 4764745 4813026 4953064 5202022 5537620 5913016 6261046 6532681 6714281 6819373 6859408 6855709 6825442 77 "Lesotho" 1989933 1986926 1987130 1990135 1995575 2003793 2014988 2028528 2043448 2059011 2075041 2091532 2108327 2125267 2142252 78 "Liberia" 3329211 3461911 3607863 3754129 3891357 4017446 4135662 4248337 4359508 4472229 4586788 4702224 4818976 4937374 5057677 79 "Libya" 5886874 5974786 6058740 6133987 6197667 6247438 6285751 6320350 6362039 6418315 6492160 6580723 6678565 6777453 6871287 80 "Madagascar" 18880265 19433520 19996476 20569115 21151640 21743970 22346641 22961259 23589897 24234080 24894370 25570511 26262313 26969306 27691019 81 "Malawi" 12973693 13341808 13727899 14128161 14539609 14962118 15396010 15839287 16289550 16745305 17205253 17670193 18143215 18628749 19129955 82 "Malaysia" 26201954 26720367 27236003 27735038 28208028 28650962 29068189 29468923 29866606 30270965 30684652 31104655 31528033 31949789 32365998 83 "Maldives" 327489 335172 343448 353391 365730 380493 397231 415592 435018 454914 475505 496398 515704 530957 540542 84 "Mali" 13203378 13651455 14113578 14581427 15049352 15514593 15979492 16449854 16934213 17438772 17965448 18512429 19077755 19658023 20250834 85 "Mauritania" 3111908 3202512 3296237 3393408 3494200 3598646 3706555 3817497 3930894 4046304 4163532 4282582 4403312 4525698 4649660 86 "Mauritius" 1233996 1239630 1244121 1247429 1250400 1252404 1255882 1258653 1260934 1262605 1263473 1264613 1265303 1265711 1265740 87 "Mexico" 107560155 109170503 110815272 112463886 114092961 115695468 117274156 118827158 120355137 121858251 123333379 124777326 126190782 127575529 128932753 88 "Micronesia" 105374 104442 103549 102971 102916 103448 104506 105922 107444 108886 110215 111461 112640 113811 115021 89 "Montenegro" 615025 615875 616969 618294 619428 620079 620601 621207 621810 622159 622303 622373 622227 622028 621306 90 "Morocco" 30804689 31163670 31536807 31929087 32343384 32781860 33241898 33715705 34192358 34663608 35126274 35581257 36029089 36471766 36910558 91 "Mozambique" 21080108 21673319 22276596 22894718 23531567 24187500 24862673 25560752 26286192 27042001 27829930 28649007 29496009 30366043 31255435 92 "Myanmar" 49301049 49621479 49929642 50250366 50600827 50990612 51413703 51852464 52280816 52680724 53045199 53382521 53708318 54045422 54409794 93 "Namibia" 1971318 2006516 2043382 2081039 2118877 2156698 2194777 2233506 2273426 2314901 2358044 2402623 2448300 2494524 2540916 94 "Nepal" 26066687 26382586 26666581 26883531 27013207 27041220 26989160 26916795 26905982 27015033 27263430 27632682 28095712 28608715 29136808 95 "New Zealand" 4184600 4223800 4259800 4302600 4350700 4384000 4408100 4442100 4516500 4609400 4714100 4813600 4900600 4979300 5084300 96 "Nicaragua" 5513757 5590066 5667436 5745538 5824058 5903035 5982530 6062462 6142734 6223234 6303970 6384843 6465502 6545503 6624554 97 "Niger" 14143969 14685404 15250913 15843131 16464025 17114770 17795209 18504287 19240182 20001663 20788789 21602388 22442831 23310719 24206636 98 "Nigeria" 142538305 146339971 150269622 154324939 158503203 162805080 167228803 171765819 176404931 181137454 185960244 190873247 195874685 200963603 206139587 99 "Macedonia" 2040228 2043559 2046898 2050671 2055004 2058539 2061044 2064032 2067471 2070226 2072490 2074502 2076217 2076694 2072531 100 end
0 Response to reshape help - error 101 variable already defined
Post a Comment