Thursday, March 4, 2021

indentify the latest year in pannel data

Hi

My sample includes firm survey in 10 countries. Each country may have more than one survey and the firm in each survey may be different. How can I pick up the latest survey in each country only. I guess I need to create a dummy variable "latest" that take the value of 1 if it is the latest survey in each year and 0 if not. Can anyone give me some hint?

Thank you very much
id employee country year gdp latest
2111 47 Afghanistan 2008 7.15 0
4386 32 Afghanistan 2008 7.15 0
5390 94 Afghanistan 2008 7.15 0
5490 73 Afghanistan 2014 7.17 1
5561 109 Afghanistan 2014 7.17 1
5582 79 Afghanistan 2014 7.17 1
5605 12 Albania 2007 5.69 0
6142 176 Albania 2007 5.69 0
6363 48 Albania 2007 5.69 0
6828 181 Albania 2013 2.4 0
7276 133 Albania 2013 2.4 0
7594 6 Albania 2019 3.12 1
7771 116 Albania 2019 3.12 1
8148 19 Albania 2019 3.12 1
8396 25 Angola 2010 8.49 1
8629 163 Angola 2010 8.49 1
8709 89 Angola 2010 8.49 1




No comments:

Post a Comment