Hi people!
I read so many posts and watched videos but I cannot find a solutions to a problem I thought it would be simpler. I need to use merge so it could work as a vlooukup in excel. so But I keep getting the message "variable ISO_YEAR does not uniquely identify observations in the master data"
My master dataset has duplicate data for some variables
COUNTRY1 YEAR1 GOOD1
COUNTRY1 YEAR1 GOOD2
COUNTRY1 YEAR1 GOOD3
COUNTRY1 YEAR2 GOOD1
COUNTRY1 YEAR2 GOOD2
COUNTRY1 YEAR2 GOOD3
COUNTRY2 YEAR1 GOOD1
COUNTRY2 YEAR1 GOOD2
COUNTRY2 YEAR1 GOOD3
COUNTRY2 YEAR2 GOOD1
COUNTRY2 YEAR2 GOOD2
COUNTRY2 YEAR2 GOOD3
etc
I need to add another variable "INCOME" from a different dataset. The income for each country for each year. The other dataset is like the following:
COUNTRY1 YEAR1 INCOME_c1y1
COUNTRY1 YEAR2 INCOME_c1y2
...
COUNTRY2 YEAR1 INCOME_c2y1
COUNTRY2 YEAR2 INCOME_c2y2
... ...
obviously I was expecting the variable to be repeated in the master data at the end. I would need something like this in my master dataset
COUNTRY1 YEAR1 GOOD1 INCOME_c1y1
COUNTRY1 YEAR1 GOOD2 INCOME_c1y1
COUNTRY1 YEAR1 GOOD3 INCOME_c1y1
COUNTRY1 YEAR2 GOOD1 INCOME_c1y2
COUNTRY1 YEAR2 GOOD2 INCOME_c1y2
COUNTRY1 YEAR2 GOOD3 INCOME_c1y2
COUNTRY2 YEAR1 GOOD1 INCOME_c2y1
COUNTRY2 YEAR1 GOOD2 INCOME_c2y1
COUNTRY2 YEAR1 GOOD3 INCOME_c2y1
COUNTRY2 YEAR2 GOOD1 INCOME_c2y2
COUNTRY2 YEAR2 GOOD2 INCOME_c2y2
COUNTRY2 YEAR2 GOOD3 INCOME_c2y2
I even concatenate the variables COUNTRY and YEAR on two datasets, so they would be ID
c1_y1
c1_y2
c2_y1
c2_y2
...
But as there are duplicates on my master dataset, I cannot complete this.
I cannot delete duplicates because I need the information of goods exported.
Is there any possible way to achieve this?
Thank you in advance!
sh
I read so many posts and watched videos but I cannot find a solutions to a problem I thought it would be simpler. I need to use merge so it could work as a vlooukup in excel. so But I keep getting the message "variable ISO_YEAR does not uniquely identify observations in the master data"
My master dataset has duplicate data for some variables
COUNTRY1 YEAR1 GOOD1
COUNTRY1 YEAR1 GOOD2
COUNTRY1 YEAR1 GOOD3
COUNTRY1 YEAR2 GOOD1
COUNTRY1 YEAR2 GOOD2
COUNTRY1 YEAR2 GOOD3
COUNTRY2 YEAR1 GOOD1
COUNTRY2 YEAR1 GOOD2
COUNTRY2 YEAR1 GOOD3
COUNTRY2 YEAR2 GOOD1
COUNTRY2 YEAR2 GOOD2
COUNTRY2 YEAR2 GOOD3
etc
I need to add another variable "INCOME" from a different dataset. The income for each country for each year. The other dataset is like the following:
COUNTRY1 YEAR1 INCOME_c1y1
COUNTRY1 YEAR2 INCOME_c1y2
...
COUNTRY2 YEAR1 INCOME_c2y1
COUNTRY2 YEAR2 INCOME_c2y2
... ...
obviously I was expecting the variable to be repeated in the master data at the end. I would need something like this in my master dataset
COUNTRY1 YEAR1 GOOD1 INCOME_c1y1
COUNTRY1 YEAR1 GOOD2 INCOME_c1y1
COUNTRY1 YEAR1 GOOD3 INCOME_c1y1
COUNTRY1 YEAR2 GOOD1 INCOME_c1y2
COUNTRY1 YEAR2 GOOD2 INCOME_c1y2
COUNTRY1 YEAR2 GOOD3 INCOME_c1y2
COUNTRY2 YEAR1 GOOD1 INCOME_c2y1
COUNTRY2 YEAR1 GOOD2 INCOME_c2y1
COUNTRY2 YEAR1 GOOD3 INCOME_c2y1
COUNTRY2 YEAR2 GOOD1 INCOME_c2y2
COUNTRY2 YEAR2 GOOD2 INCOME_c2y2
COUNTRY2 YEAR2 GOOD3 INCOME_c2y2
I even concatenate the variables COUNTRY and YEAR on two datasets, so they would be ID
c1_y1
c1_y2
c2_y1
c2_y2
...
But as there are duplicates on my master dataset, I cannot complete this.
I cannot delete duplicates because I need the information of goods exported.
Is there any possible way to achieve this?
Thank you in advance!
sh

Comment