Hello Stata Users,
I am trying to combine two different data sets according to the variables "Area" and "Year". While observations of these variables are common in both data sets, after using the merge command, observations of the same year and the same country appear in different rows. The reason for this is that, in a dataset, the names of the countries appear first in the cell, followed by a space.
I am adding a sample from one of the data sets below. Besides, I am adding the list of Area according to tag after merging. How can I deal with this problem? Thank you in advance.

Best,


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str35 Area int Year float(avr_precip avr_temp)
" Afghanistan" 1961  355969.9  276361.9
" Afghanistan" 1962  415947.5  230001.1
" Afghanistan" 1963  481006.8  328412.2
" Afghanistan" 1964  262749.5  243936.5
" Afghanistan" 1965  426870.7 203707.33
" Afghanistan" 1966  446330.1 281000.16
" Afghanistan" 1967  487800.4 262055.25
" Afghanistan" 1968  423439.6 261638.83
" Albania"     1961 509769.75    302613
" Albania"     1962  347457.3 245861.33
" Albania"     1963  392791.9  202664.4
" Albania"     1964    372516    247544
" Albania"     1965  342288.5    344300
" Albania"     1966  406166.6  297721.6
" Albania"     1967    374308 312650.25
" Albania"     1968  447654.3 230648.33
end
merge m:m Area Year using "C:\Users\simay\Desktop\all_merged_atfp_climat e_an alysis(no_zero_coundum).dta"
(note: variable Area was str35, now str52 to accommodate using data's values)

Result # of obs.
-----------------------------------------
not matched 23,802
from master 10,080 (_merge==1)
from using 13,722 (_merge==2)

matched 840 (_merge==3)
-----------------------------------------


+----------------------------------------------+
| Area |
|----------------------------------------------|
1. | Afghanistan |
57. | Albania |
113. | Algeria |
169. | Andorra |
225. | Angola |
|----------------------------------------------|
281. | Antigua and Barbuda |
337. | Argentina |
393. | Armenia |
449. | Australia |
505. | Austria |
|----------------------------------------------|
561. | Azerbaijan |
617. | Bahamas |
673. | Bahrain |
729. | Bangladesh |
785. | Barbados |
|----------------------------------------------|
841. | Belarus |
897. | Belgium |
953. | Belize |
1009. | Benin |
1065. | Bhutan |
|----------------------------------------------|
1121. | Bolivia |
1177. | Bosnia and Herzegovina |
1233. | Botswana |
1289. | Brazil |
1345. | Brunei |
|----------------------------------------------|
1401. | Bulgaria |
1457. | Burkina Faso |
1513. | Burundi |
1569. | Cambodia |
1625. | Cameroon |
|----------------------------------------------|
1681. | Canada |
1737. | Cape Verde |
1793. | Central African Republic |
1849. | Chad |
1905. | Chile |
|----------------------------------------------|
1961. | China |
2017. | Colombia |
2073. | Comoros |
2129. | Costa Rica |
2185. | Croatia |
|----------------------------------------------|
2241. | Cuba |
2297. | Cyprus |
2353. | Czech Republic |
2409. | Denmark |
2465. | Djibouti |
|----------------------------------------------|
2521. | Dominica |
2577. | Dominican Republic |
2633. | Ecuador |
2689. | Egypt |
2745. | El Salvador |
|----------------------------------------------|
2801. | Equatorial Guinea |
2857. | Eritrea |
2913. | Estonia |
2969. | Ethiopia |
3025. | Faroe Islands |
|----------------------------------------------|
3081. | Fiji |
3137. | Finland |
3193. | France |
3249. | Gabon |
3305. | Gambia |
|----------------------------------------------|
3361. | Georgia |
3417. | Germany |
3473. | Ghana |
3529. | Greece |
3585. | Greenland |
|----------------------------------------------|
3641. | Grenada |
3697. | Guatemala |
3753. | Guinea |
3809. | Guinea-Bissau |
3865. | Guyana |
|----------------------------------------------|
3921. | Haiti |
3977. | Honduras |
4033. | Hungary |
4089. | Iceland |
4145. | India |
|----------------------------------------------|
4201. | Indonesia |
4257. | Iraq |
4313. | Ireland |
4369. | Israel |
4425. | Italy |
|----------------------------------------------|
4481. | Jamaica |
4537. | Japan |
4593. | Jordan |
4649. | Kazakhstan |
4705. | Kenya |
|----------------------------------------------|
4761. | Kiribati |
4817. | Korea |
4873. | Kuwait |
4929. | Latvia |
4985. | Lebanon |
|----------------------------------------------|
5041. | Lesotho |
5097. | Liberia |
5153. | Libya |
5209. | Liechtenstein |
5265. | Lithuania |
|----------------------------------------------|
5321. | Luxembourg |
5377. | Macedonia |
5433. | Madagascar |
5489. | Malawi |
5545. | Malaysia |
|----------------------------------------------|
5601. | Maldives |
5657. | Mali |
5713. | Malta |
5769. | Marshall Islands |
5825. | Mauritania |
|----------------------------------------------|
5881. | Mauritius |
5937. | Mexico |
5993. | Moldova |
6049. | Monaco |
6105. | Mongolia |
|----------------------------------------------|
6161. | Morocco |
6217. | Mozambique |
6273. | Namibia |
6329. | Nepal |
6385. | Netherlands |
|----------------------------------------------|
6441. | New Caledonia |
6497. | New Zealand |
6553. | Nicaragua |
6609. | Niger |
6665. | Nigeria |
|----------------------------------------------|
6721. | Northern Mariana Islands |
6777. | Norway |
6833. | Oman |
6889. | Pakistan |
6945. | Palau |
|----------------------------------------------|
7001. | Panama |
7057. | Papua New Guinea |
7113. | Paraguay |
7169. | Peru |
7225. | Philippines |
|----------------------------------------------|
7281. | Poland |
7337. | Portugal |
7393. | Puerto Rico |
7449. | Qatar |
7505. | Romania |
|----------------------------------------------|
7561. | Rwanda |
7617. | Samoa |
7673. | Sao Tome and Principe |
7729. | Saudi Arabia |
7785. | Senegal |
|----------------------------------------------|
7841. | Seychelles |
7897. | Sierra Leone |
7953. | Singapore |
8009. | Slovakia |
8065. | Slovenia |
|----------------------------------------------|
8121. | Solomon Islands |
8177. | Somalia |
8233. | South Africa |
8289. | South Sudan |
8345. | Spain |
|----------------------------------------------|
8401. | Sri Lanka |
8457. | St. Kitts and Nevis |
8513. | St. Lucia |
8569. | St. Vincent and the Grenadines |
8625. | Sudan |
|----------------------------------------------|
8681. | Suriname |
8737. | Swaziland |
8793. | Sweden |
8849. | Switzerland |
8905. | Tajikistan |
|----------------------------------------------|
8961. | Thailand |
9017. | Togo |
9073. | Tonga |
9129. | Trinidad and Tobago |
9185. | Tunisia |
|----------------------------------------------|
9241. | Turkey |
9297. | Turkmenistan |
9353. | Tuvalu |
9409. | Uganda |
9465. | Ukraine |
|----------------------------------------------|
9521. | United Arab Emirates |
9577. | United Kingdom |
9633. | Uruguay |
9689. | Uzbekistan |
9745. | Vanuatu |
|----------------------------------------------|
9801. | Venezuela |
9857. | Vietnam |
9913. | Yemen |
9969. | Zambia |
10025. | Zimbabwe |
|----------------------------------------------|
10081. | Congo |
10137. | Congo, Dem. Rep. |
10193. | Côte d'Ivoire |
10249. | Iran (Islamic Republic of) |
10305. | Kyrgyz Rep. |
|----------------------------------------------|
10361. | Lao People's Democratic Republic |
10417. | Micronesia (Federated States of) |
10473. | Montenegro |
10529. | Myanmar |
10585. | Russian Federation |
|----------------------------------------------|
10641. | Serbia |
10697. | Syrian Arab Republic |
10753. | Timor-Leste |
10809. | United Republic of Tanzania |
10865. | United States of America |
|----------------------------------------------|
10921. | Afghanistan |
10984. | Albania |
11049. | Algeria |
11118. | American Samoa |
11178. | Andorra |
|----------------------------------------------|
11238. | Angola |
11299. | Anguilla |
11364. | Antigua and Barbuda |
11425. | Argentina |
11488. | Armenia |
|----------------------------------------------|
11549. | Aruba |
11609. | Australia |
11677. | Austria |
11739. | Azerbaijan |
11800. | Bahamas |
|----------------------------------------------|
11864. | Bahrain |
11924. | Bangladesh |
12000. | Barbados |
12061. | Belarus |
12122. | Belgium |
|----------------------------------------------|
12219. | Belgium-Luxembourg |
12275. | Belize |
12337. | Benin |
12397. | Bermuda |
12458. | Bhutan |
|----------------------------------------------|
12518. | Bolivia |
12578. | Bosnia and Herzegovina |
12638. | Botswana |
12698. | Brazil |
12768. | British Virgin Islands |
|----------------------------------------------|
12828. | Brunei Darussalam |
12888. | Bulgaria |
12950. | Burkina Faso |
13012. | Burundi |
13072. | Cambodia |
|----------------------------------------------|
13132. | Cameroon |
13192. | Canada |
13285. | Cape Verde |
13341. | Cayman Islands |
13401. | Central African Republic |
|----------------------------------------------|
13461. | Chad |
13523. | Channel Islands |
13583. | Chile |
13653. | China |
13758. | China, Taiwan Province of |
|----------------------------------------------|
13836. | China, mainland |
13894. | Colombia |
13965. | Comoros |
14039. | Costa Rica |
14102. | Croatia |
|----------------------------------------------|
14162. | Cuba |
14227. | Cyprus |
14288. | Czech Republic |
14348. | Czechoslovakia |
14411. | Democratic People's Republic of Korea |
|----------------------------------------------|
14471. | Denmark |
14532. | Djibouti |
14592. | Dominica |
14653. | Dominican Republic |
14715. | Ecuador |
|----------------------------------------------|
14781. | Egypt |
14846. | El Salvador |
14909. | Equatorial Guinea |
14969. | Eritrea |
15029. | Estonia |
|----------------------------------------------|
15089. | Ethiopia |
15150. | Ethiopia, former |
15206. | Faroe Islands |
15266. | Fiji |
15331. | Finland |
|----------------------------------------------|
15392. | France |
15471. | French Guiana |
15529. | French Polynesia |
15590. | Gabon |
15650. | Gambia |
|----------------------------------------------|
15712. | Georgia |
15772. | Germany |
15846. | Ghana |
15908. | Gibraltar |
15968. | Greece |
|----------------------------------------------|
16041. | Greenland |
16101. | Grenada |
16161. | Guadeloupe |
16221. | Guam |
16281. | Guatemala |
|----------------------------------------------|
16345. | Guinea |
16405. | Guinea-Bissau |
16467. | Guyana |
16527. | Haiti |
16593. | Honduras |
|----------------------------------------------|
16655. | Hong Kong SAR, China |
16714. | Hungary |
16775. | Iceland |
16835. | India |
16927. | Indonesia |
|----------------------------------------------|
17037. | Iraq |
17098. | Ireland |
17159. | Isle of Man |
17219. | Israel |
17281. | Italy |
|----------------------------------------------|
17360. | Jamaica |
17435. | Japan |
17534. | Jordan |
17595. | Kazakhstan |
17656. | Kenya |
|----------------------------------------------|
17717. | Kiribati |
17777. | Kuwait |
17845. | Latvia |
17905. | Lebanon |
17967. | Lesotho |
|----------------------------------------------|
18027. | Lesser Antilles |
18083. | Liberia |
18143. | Libya |
18204. | Liechtenstein |
18264. | Lithuania |
|----------------------------------------------|
18324. | Luxembourg |
18384. | Macao SAR, China |
18444. | Macedonia |
18503. | Madagascar |
18564. | Malawi |
|----------------------------------------------|
18624. | Malaysia |
18684. | Maldives |
18744. | Mali |
18806. | Malta |
18866. | Marshall Islands |
|----------------------------------------------|
18926. | Martinique |
18986. | Mauritania |
19048. | Mauritius |
19108. | Mayotte |
19166. | Mexico |
|----------------------------------------------|
19244. | Moldova |
19304. | Mongolia |
19370. | Montserrat |
19397. | Morocco |
19462. | Mozambique |
|----------------------------------------------|
19533. | Namibia |
19593. | Nauru |
19653. | Nepal |
19714. | Netherlands |
19778. | Netherlands Antilles (former) |
|----------------------------------------------|
19838. | New Caledonia |
19903. | New Zealand |
19969. | Nicaragua |
20032. | Niger |
20099. | Nigeria |
|----------------------------------------------|
20160. | Northern Mariana Islands |
20220. | Norway |
20282. | Oman |
20342. | Pakistan |
20416. | Palau |
|----------------------------------------------|
20476. | Panama |
20536. | Papua New Guinea |
20599. | Paraguay |
20659. | Peru |
20732. | Philippines |
|----------------------------------------------|
20816. | Poland |
20879. | Portugal |
20941. | Puerto Rico |
21006. | Qatar |
21066. | Republic of Korea |
|----------------------------------------------|
21132. | Romania |
21207. | Rwanda |
21268. | Réunion |
21326. | Saint Helena, Ascension and Tristan da Cunha |
21384. | Saint Pierre and Miquelon |
|----------------------------------------------|
21442. | Samoa |
21502. | Sao Tome and Principe |
21562. | Saudi Arabia |
21622. | Senegal |
21688. | Serbia and Montenegro |
|----------------------------------------------|
21744. | Seychelles |
21804. | Sierra Leone |
21864. | Singapore |
21924. | Slovakia |
21984. | Slovenia |
|----------------------------------------------|
22044. | Solomon Islands |
22106. | Somalia |
22166. | South Africa |
22229. | South Sudan |
22289. | Spain |
|----------------------------------------------|
22357. | Sri Lanka |
22418. | St. Kitts and Nevis |
22480. | St. Lucia |
22540. | St. Vincent and the Grenadines |
22602. | Sudan |
|----------------------------------------------|
22662. | Sudan (former) |
22721. | Suriname |
22781. | Swaziland |
22839. | Sweden |
22901. | Switzerland |
|----------------------------------------------|
22968. | Tajikistan |
23030. | Thailand |
23094. | Togo |
23154. | Tonga |
23215. | Trinidad and Tobago |
|----------------------------------------------|
23276. | Tunisia |
23337. | Turkey |
23426. | Turkmenistan |
23486. | Turks and Caicos Islands |
23546. | Tuvalu |
|----------------------------------------------|
23607. | USSR |
23678. | Uganda |
23740. | Ukraine |
23800. | United Arab Emirates |
23860. | United Kingdom |
|----------------------------------------------|
23925. | United States Virgin Islands |
24038. | Uruguay |
24098. | Uzbekistan |
24158. | Vanuatu |
24221. | Venezuela |
|----------------------------------------------|
24284. | Vietnam |
24346. | West Bank and Gaza |
24406. | Yemen |
24466. | Yugoslav SFR |
24523. | Zambia |
|----------------------------------------------|
24583. | Zimbabwe |
+----------------------------------------------+