Hi,
I am posting a sample from my main data. I want to perform calculation of variable 1 and variable 2 per country per year. So the dataset looks like this:
How I want my data:
SO as you can see now I have data per year and per country. Instead of repeating years for each observation. Can you help me with the code. And I also want to retain year code and country.
Best Regards,
Abdullah
I am posting a sample from my main data. I want to perform calculation of variable 1 and variable 2 per country per year. So the dataset looks like this:
Code:
year code country Variable 1 Variable 2 1990 11 Argentina 1 0 1990 11 Argentina 2 1 1991 11 Argentina 3 2 1991 11 Argentina 4 1 1990 12 Bangladesh 1 5 1990 12 Bangladesh 2 2 1991 12 Bangladesh 3 1 1991 12 Bangladesh 4 2 1990 13 Cameroon 0 0 1990 13 Cameroon 0 0 1991 13 Cameroon 0 1 1991 13 Cameroon 1 0
How I want my data:
Code:
year code country Variable 1 Variable 2 1990 11 Argentina 3 1 1991 11 Argentina 7 3 1990 12 Bangladesh 3 7 1991 12 Bangladesh 7 3 1990 13 Cameroon 0 0 1991 13 Cameroon 1 1
SO as you can see now I have data per year and per country. Instead of repeating years for each observation. Can you help me with the code. And I also want to retain year code and country.
Best Regards,
Abdullah
Comment