Hello,
I'm cleaning a huge dataset and I'm stucked in one point. I've find similar problems and nice answers in here but the structures are slightly different from mine and I can not apply this to my issue.
I have data on trade for lots of countries and years. My data for now looks like this (numbers are fake):
And I want to merge/combine all the pairs of variables that have the same contry 1, country 2 and year, which have the same values for all the variables but "imp" and "exp", which each ones take . (missing value) in one case. So, I want to have something like this:
And therefore, have the half of the observations than before.
Many thanks for your help!!
I'm cleaning a huge dataset and I'm stucked in one point. I've find similar problems and nice answers in here but the structures are slightly different from mine and I can not apply this to my issue.
I have data on trade for lots of countries and years. My data for now looks like this (numbers are fake):
| country_1 | country_2 | year | imp | exp | "other variables" | |
| 1 | greece | united_kingdom | 1857 | 124353.66 | . | XX |
| 2 | greece | united_kingdom | 1857 | . | 4659756.67 | XX |
| 3 | greece | united_kingdom | 1858 | 574974.86 | . | XX |
| 4 | greece | united_kingdom | 1858 | . | 658796.34 | XX |
| ...... | .............. | ..................... | ..... | ................. | ............... | ............. |
| 99 | greece | belgium | 1857 | 56746.67 | . | XX |
| 100 | greece | belgium | 1857 | . | 45675.67 | XX |
And I want to merge/combine all the pairs of variables that have the same contry 1, country 2 and year, which have the same values for all the variables but "imp" and "exp", which each ones take . (missing value) in one case. So, I want to have something like this:
| country_1 | country_2 | year | imp | exp | "other variables" | |
| 1 | greece | united_kingdom | 1857 | 124353.66 | 4659756.67 | XX |
| 2 | greece | united_kingdom | 1858 | 574974.86 | 658796.34 | XX |
| ..... | .............. | ..................... | ..... | ................. | ............... | XX |
| 50 | greece | belgium | 1857 | 56746.67 | 45675.67 | XX |
And therefore, have the half of the observations than before.
Many thanks for your help!!

Comment