Hi I would like to separate the contents of the string variable 'gazetteer_adm_name' to different variables based on the hyphen separation. For eg) for "Earth|Africa|Kenya|Nandi|Kapsabet" I want Variable 1 to have Earth, Variable 2 to have Africa, Variable 3 to have Kenya, Variable 4 to have Nnadi and Variable 5 to have Kapsabet.If only four hyphenated places are given then the fifth variable should be left empty.
Code:
dataex ID_0 ID_1 ID_2 geoname_id precision_code place_name gazetteer_adm_code gazetteer_adm_name location_type_name ----------------------- copy starting from the next line ----------------------------------------- copy up to and including the previous line ------------------Code:* Example generated by -dataex-. To install: ssc install dataex clear input int ID_0 byte ID_1 int ID_2 long geoname_id byte precision_code str62 place_name str53 gazetteer_adm_code str123 gazetteer_adm_name str47 location_type_name 118 31 214 184622 1 "Nakuru" "6295630|6255146|KE|39|184622" "Earth|Africa|Kenya|Nakuru|Nakuru" "seat of a first-order administrative division" 118 32 221 194038 1 "Kapsabet" "6295630|6255146|KE|40|194038" "Earth|Africa|Kenya|Nandi|Kapsabet" "seat of a first-order administrative division" 118 10 58 189723 1 "Langata Rongai" "6295630|6255146|KE|05|189723" "Earth|Africa|Kenya|Nairobi|Langata Rongai" "populated place" 118 30 207 181656 1 "Parklands" "6295630|6255146|KE|05|184745|181656" "Earth|Africa|Kenya|Nairobi|Nairobi|Parklands" "section of populated place" 118 28 182 186301 1 "Mombasa" "6295630|6255146|KE|37|186301" "Earth|Africa|Kenya|Mombasa|Mombasa" "seat of a first-order administrative division" 118 1 2 195821 1 "Kabarnet" "6295630|6255146|KE|10|195821" "Earth|Africa|Kenya|Baringo|Kabarnet" "seat of a first-order administrative division" 118 23 147 188080 1 "Makueni" "6295630|6255146|KE|32|188080" "Earth|Africa|Kenya|Makueni|Makueni" "populated place" 118 12 72 192900 1 "Kericho" "6295630|6255146|KE|21|192900" "Earth|Africa|Kenya|Kericho|Kericho" "seat of a first-order administrative division" 118 4 27 199989 1 "Busia" "6295630|6255146|KE|13|199989" "Earth|Africa|Kenya|Busia|Busia" "seat of a first-order administrative division" 118 16 107 191299 1 "Kisii" "6295630|6255146|KE|25|191299" "Earth|Africa|Kenya|Kisii|Kisii" "seat of a first-order administrative division" 118 30 191 178147 1 "Westlands" "6295630|6255146|KE|05|184745|178147" "Earth|Africa|Kenya|Nairobi|Nairobi|Westlands" "section of populated place" 118 3 15 200067 1 "Bungoma" "6295630|6255146|KE|12|200067" "Earth|Africa|Kenya|Bungoma|Bungoma" "seat of a first-order administrative division" 118 30 202 188184 1 "Makadara" "6295630|6255146|KE|05|184745|188184" "Earth|Africa|Kenya|Nairobi|Nairobi|Makadara" "section of populated place" 118 30 197 8477681 1 "Umoja 1" "6295630|6255146|KE|05|184745|8477681" "Earth|Africa|Kenya|Nairobi|Nairobi|Umoja 1" "section of populated place" 118 14 95 187968 1 "Malindi" "6295630|6255146|KE|23|187968" "Earth|Africa|Kenya|Kilifi|Malindi" "populated place" 118 30 194 198516 1 "Embakasi" "6295630|6255146|KE|05|198516" "Earth|Africa|Kenya|Nairobi|Embakasi" "populated place" 118 30 194 8477684 1 "Umoja 2" "6295630|6255146|KE|05|184745|8477684" "Earth|Africa|Kenya|Nairobi|Nairobi|Umoja 2" "section of populated place" 118 29 188 185579 1 "Murang’a" "6295630|6255146|KE|38|185579" "Earth|Africa|Kenya|Murang'A|Murang’a" "seat of a first-order administrative division" 118 30 207 8477638 1 "Gigiri" "6295630|6255146|KE|05|184745|8477638" "Earth|Africa|Kenya|Nairobi|Nairobi|Gigiri" "section of populated place" 118 30 199 8693323 1 "Kasarani" "6295630|6255146|KE|05|197663|8693323" "Earth|Africa|Kenya|Nairobi|Gatharaini|Kasarani" "section of populated place" 118 26 166 186827 1 "Meru" "6295630|6255146|KE|35|186827" "Earth|Africa|Kenya|Meru|Meru" "seat of a first-order administrative division" 118 36 243 182701 1 "Nyeri" "6295630|6255146|KE|44|182701" "Earth|Africa|Kenya|Nyeri|Nyeri" "seat of a first-order administrative division" 118 14 94 181504 2 "Pumwani" "6295630|6255146|KE|23|181504" "Earth|Africa|Kenya|Kilifi|Pumwani" "area" 118 10 56 195298 1 "Kajiado" "6295630|6255146|KE|19|195298" "Earth|Africa|Kenya|Kajiado|Kajiado" "seat of a first-order administrative division" 118 39 257 178522 1 "Voi" "6295630|6255146|KE|47|178522" "Earth|Africa|Kenya|Taita Taveta|Voi" "populated place" 118 42 271 191220 1 "Kitale" "6295630|6255146|KE|50|191220" "Earth|Africa|Kenya|Trans Nzoia|Kitale" "seat of a first-order administrative division" 118 7 42 197745 1 "Garissa" "6295630|6255146|KE|16|197745" "Earth|Africa|Kenya|Garissa|Garissa" "seat of a first-order administrative division" 118 30 201 8477691 1 "Karen" "6295630|6255146|KE|05|184745|8477691" "Earth|Africa|Kenya|Nairobi|Nairobi|Karen" "section of populated place" 118 6 35 198476 1 "Embu" "6295630|6255146|KE|15|198476" "Earth|Africa|Kenya|Embu|Embu" "seat of a first-order administrative division" 118 11 65 195272 1 "Kakamega" "6295630|6255146|KE|20|195272" "Earth|Africa|Kenya|Kakamega|Kakamega" "seat of a first-order administrative division" 118 30 206 184745 1 "Nairobi" "6295630|6255146|KE|05|184745" "Earth|Africa|Kenya|Nairobi|Nairobi" "capital of a political entity" 118 44 280 198629 1 "Eldoret" "6295630|6255146|KE|52|198629" "Earth|Africa|Kenya|Uasin Gishu|Eldoret" "seat of a first-order administrative division" 118 8 46 196742 1 "Homa Bay" "6295630|6255146|KE|17|196742" "Earth|Africa|Kenya|Homa Bay|Homa Bay" "seat of a first-order administrative division" 118 33 228 184379 1 "Narok" "6295630|6255146|KE|41|184379" "Earth|Africa|Kenya|Narok|Narok" "seat of a first-order administrative division" 118 30 197 199108 1 "Dandora" "6295630|6255146|KE|05|199108" "Earth|Africa|Kenya|Nairobi|Dandora" "populated place" 118 22 137 188492 1 "Machakos" "6295630|6255146|KE|31|188492" "Earth|Africa|Kenya|Machakos|Machakos" "seat of a first-order administrative division" 118 13 89 179330 1 "Thika" "6295630|6255146|KE|05|179330" "Earth|Africa|Kenya|Nairobi|Thika" "populated place" 118 17 110 191245 1 "Kisumu" "6295630|6255146|KE|26|191245" "Earth|Africa|Kenya|Kisumu|Kisumu" "seat of a first-order administrative division" 118 7 43 8299464 3 "Ijara District" "6295630|6255146|KE|16|8299464" "Earth|Africa|Kenya|Garissa|Ijara District" "second-order administrative division" 118 40 260 179585 4 "Tana River" "6295630|6255146|KE|48" "Earth|Africa|Kenya|Tana River" "first-order administrative division" 118 37 246 192950 6 "Kenya" "6295630|6255146|KE" "Earth|Africa|Kenya" "independent political entity" 118 37 246 180782 4 "Samburu" "6295630|6255146|KE|45" "Earth|Africa|Kenya|Samburu" "first-order administrative division" 118 25 157 7733024 3 "Moyale District" "6295630|6255146|KE|34|7733024" "Earth|Africa|Kenya|Marsabit|Moyale District" "second-order administrative division" 118 7 41 197744 4 "Garissa" "6295630|6255146|KE|16" "Earth|Africa|Kenya|Garissa" "first-order administrative division" 118 43 273 178914 4 "Turkana" "6295630|6255146|KE|51" "Earth|Africa|Kenya|Turkana" "first-order administrative division" 118 24 153 187895 4 "Mandera" "6295630|6255146|KE|33" "Earth|Africa|Kenya|Mandera" "first-order administrative division" 118 9 54 196228 4 "Isiolo" "6295630|6255146|KE|18" "Earth|Africa|Kenya|Isiolo" "first-order administrative division" 118 1 3 200573 4 "Baringo" "6295630|6255146|KE|10" "Earth|Africa|Kenya|Baringo" "first-order administrative division" 118 46 292 178440 4 "Wajir" "6295630|6255146|KE|54" "Earth|Africa|Kenya|Wajir" "first-order administrative division" 118 25 158 187583 4 "Marsabit" "6295630|6255146|KE|34" "Earth|Africa|Kenya|Marsabit" "first-order administrative division" 118 28 182 186301 1 "Mombasa" "6295630|6255146|KE|37|186301" "Earth|Africa|Kenya|Mombasa|Mombasa" "seat of a first-order administrative division" 118 37 246 192950 6 "Kenya" "6295630|6255146|KE" "Earth|Africa|Kenya" "independent political entity" 118 37 246 192950 6 "Kenya" "6295630|6255146|KE" "Earth|Africa|Kenya" "independent political entity" 118 17 114 186611 2 "Miriu" "6295630|6255146|KE|00" "Earth|Africa|Kenya|Miriu" "stream" 118 37 246 192950 8 "Kenya" "6295630|6255146|KE" "Earth|Africa|Kenya" "independent political entity" 118 30 206 184745 1 "Nairobi" "6295630|6255146|KE|05|184745" "Earth|Africa|Kenya|Nairobi|Nairobi" "capital of a political entity" 118 28 178 191679 1 "Kipevu" "6295630|6255146|KE|37|191679" "Earth|Africa|Kenya|Mombasa|Kipevu" "area" 118 13 82 197297 1 "Gitaru" "6295630|6255146|KE|22|197297" "Earth|Africa|Kenya|Kiambu|Gitaru" "populated place" 118 8 53 188150 2 "Makende" "6295630|6255146|KE|17|188150" "Earth|Africa|Kenya|Homa Bay|Makende" "hill" 118 31 213 182245 1 "Olkaria" "6295630|6255146|KE|19|182245" "Earth|Africa|Kenya|Kajiado|Olkaria" "area" 118 29 189 182722 1 "Nyati" "6295630|6255146|KE|38|182722" "Earth|Africa|Kenya|Murang'A|Nyati" "populated place" 118 19 128 8356717 1 "Diani" "6295630|6255146|KE|28|8356717" "Earth|Africa|Kenya|Kwale|Diani" "populated place" 118 31 213 184707 1 "Naivasha" "6295630|6255146|KE|39|184707" "Earth|Africa|Kenya|Nakuru|Naivasha" "populated place" 118 14 95 187968 1 "Malindi" "6295630|6255146|KE|23|187968" "Earth|Africa|Kenya|Kilifi|Malindi" "populated place" 118 28 182 186301 1 "Mombasa" "6295630|6255146|KE|37|186301" "Earth|Africa|Kenya|Mombasa|Mombasa" "seat of a first-order administrative division" 118 37 246 192950 6 "Kenya" "6295630|6255146|KE" "Earth|Africa|Kenya" "independent political entity" 126 10 0 932692 8 "Lesotho" "6295630|6255146|LS" "Earth|Africa|Lesotho" "independent political entity" 126 9 0 932943 1 "Alwyns Kop" "6295630|6255146|LS|00" "Earth|Africa|Lesotho|Alwyns Kop" "populated place" 126 5 0 932506 4 "Maseru" "6295630|6255146|LS|14" "Earth|Africa|Lesotho|Maseru" "first-order administrative division" 126 8 0 932327 1 "Mpite" "6295630|6255146|LS|00" "Earth|Africa|Lesotho|Mpite" "populated place" 126 8 0 932219 4 "Qacha’s Nek" "6295630|6255146|LS|17" "Earth|Africa|Lesotho|Qacha’s Nek" "first-order administrative division" 126 7 0 932418 4 "Mokhotlong" "6295630|6255146|LS|16" "Earth|Africa|Lesotho|Mokhotlong" "first-order administrative division" 126 2 0 932888 4 "Butha-Buthe" "6295630|6255146|LS|11" "Earth|Africa|Lesotho|Butha-Buthe" "first-order administrative division" 126 1 0 932035 1 "Teyateyaneng" "6295630|6255146|LS|10|932035" "Earth|Africa|Lesotho|Berea|Teyateyaneng" "seat of a first-order administrative division" 126 10 0 932692 6 "Lesotho" "6295630|6255146|LS" "Earth|Africa|Lesotho" "independent political entity" 126 8 0 963306 1 "Ramatšeliso’s Nek" "6295630|6255146|ZA|00" "Earth|Africa|South Africa|Ramatšeliso’s Nek" "pass" 126 5 0 7522153 2 "Likalaneng Community" "6295630|6255146|LS|19|7522153" "Earth|Africa|Lesotho|Thaba-Tseka|Likalaneng Community" "third-order administrative division" 126 6 0 932079 5 "Senqunyane" "6295630|6255146|LS|00" "Earth|Africa|Lesotho|Senqunyane" "stream" 126 10 0 6941916 1 "Katse Dam" "6295630|6255146|LS|19|6941916" "Earth|Africa|Lesotho|Thaba-Tseka|Katse Dam" "reservoir(s)" 126 10 0 932534 5 "Mantsonyane River" "6295630|6255146|LS|00" "Earth|Africa|Lesotho|Mantsonyane River" "stream" 126 7 0 7576068 2 "Matsoku Community" "6295630|6255146|LS|12|7576068" "Earth|Africa|Lesotho|Leribe|Matsoku Community" "third-order administrative division" 126 6 0 932438 1 "Mohale's Hoek" "6295630|6255146|LS|15|932438" "Earth|Africa|Lesotho|Mohale’s Hoek District|Mohale's Hoek" "seat of a first-order administrative division" 134 4 13 1062663 1 "Mahajanga" "6295630|6255146|MG|7670849|1062663" "Earth|Africa|Madagascar|Boeny Region|Mahajanga" "seat of a first-order administrative division" 134 1 1 10171155 1 "Mandraka Dam" "6295630|6255146|MG|10171155" "Earth|Africa|Madagascar|Mandraka Dam" "dam" 134 1 1 7701357 1 "Antelomita" "6295630|6255146|MG|7701357" "Earth|Africa|Madagascar|Antelomita" "dam" 134 1 4 1061399 1 "Manandona" "6295630|6255146|MG|05" "Earth|Africa|Madagascar|Manandona" "populated place" 134 3 11 7670906 4 "Vatovavy Fitovinany Region" "6295630|6255146|MG|7670906" "Earth|Africa|Madagascar|Vatovavy Fitovinany Region" "first-order administrative division" 134 1 4 1062947 6 "Madagascar" "6295630|6255146|MG" "Earth|Africa|Madagascar" "independent political entity" 134 3 11 1061605 1 "Manakara" "6295630|6255146|MG|7670906|1061605" "Earth|Africa|Madagascar|Vatovavy Fitovinany Region|Manakara" "seat of a first-order administrative division" 134 5 18 7698632 1 "Volobe" "6295630|6255146|MG|7698632" "Earth|Africa|Madagascar|Volobe" "dam" 134 3 11 1061335 1 "Mananjary" "6295630|6255146|MG|7670906|1061335" "Earth|Africa|Madagascar|Vatovavy Fitovinany Region|Mananjary" "populated place" 134 4 13 7670849 4 "Boeny Region" "6295630|6255146|MG|7670849" "Earth|Africa|Madagascar|Boeny Region" "first-order administrative division" 134 3 11 1058280 1 "Namorona" "6295630|6255146|MG|02" "Earth|Africa|Madagascar|Namorona" "populated place" 134 1 4 1062947 6 "Madagascar" "6295630|6255146|MG" "Earth|Africa|Madagascar" "independent political entity" 134 1 1 1073482 1 "Anjozorobe" "6295630|6255146|MG|7670856|1073482" "Earth|Africa|Madagascar|Analamanga Region|Anjozorobe" "populated place" 134 6 21 1057095 2 "Sakaraha" "6295630|6255146|MG|7670913|1057095" "Earth|Africa|Madagascar|Atsimo-Andrefana Region|Sakaraha" "populated place" 134 2 5 7932431 5 "Montagne D'Ambre National Park" "6295630|6255146|MG|7932431" "Earth|Africa|Madagascar|Montagne D'Ambre National Park" "park" 134 3 9 1057197 2 "Sakafia" "6295630|6255146|MG|02" "Earth|Africa|Madagascar|Sakafia" "populated place" 134 3 9 1064890 1 "Fianarantsoa" "6295630|6255146|MG|7670905|1064890" "Earth|Africa|Madagascar|Upper Matsiatra|Fianarantsoa" "seat of a first-order administrative division" 134 3 9 7670903 3 "Fianarantsoa I" "6295630|6255146|MG|7670905|7670903" "Earth|Africa|Madagascar|Upper Matsiatra|Fianarantsoa I" "second-order administrative division" end
Comment