I have the following dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year long gid float nactors2 double nactorsNEW int country_code float(longitude latitude) 1999 136452 1 1 566 5.75 4.75 2002 136452 . 1 . . . 2003 136452 . 1 . . . 2004 136452 1 1 566 5.75 4.75 2005 136452 2 2 566 5.75 4.75 2006 136452 2 2 566 5.75 4.75 2007 136452 . 2 . . . 2008 136452 2 2 566 5.75 4.75 2009 136452 1 1 566 5.75 4.75 2010 136452 . 1 . . . 2011 136452 . 1 . . . 2012 136452 1 1 566 5.75 4.75 2013 136452 2 2 566 5.75 4.75 2014 136452 1 1 566 5.75 4.75 2015 136452 1 1 566 5.75 4.75 2016 136452 1 1 566 5.75 4.75 2017 136452 2 2 566 5.75 4.75 2018 136452 . 2 . . . 2019 136452 2 2 566 5.75 4.75 2020 136452 2 2 566 5.75 4.75 1997 136453 1 1 566 6.25 4.75 1998 136453 2 2 566 6.25 4.75 1999 136453 3 3 566 6.25 4.75 2002 136453 1 1 566 6.25 4.75 2003 136453 2 2 566 6.25 4.75 2004 136453 1 1 566 6.25 4.75 2005 136453 1 1 566 6.25 4.75 2006 136453 2 2 566 6.25 4.75 2007 136453 1 1 566 6.25 4.75 2008 136453 4 4 566 6.25 4.75 2009 136453 4 4 566 6.25 4.75 2010 136453 2 2 566 6.25 4.75 2011 136453 1 1 566 6.25 4.75 2012 136453 1 1 566 6.25 4.75 2013 136453 2 2 566 6.25 4.75 2014 136453 2 2 566 6.25 4.75 2015 136453 3 3 566 6.25 4.75 2016 136453 4 4 566 6.25 4.75 2017 136453 3 3 566 6.25 4.75 2018 136453 1 1 566 6.25 4.75 2019 136453 3 3 566 6.25 4.75 2020 136453 8 8 566 6.25 4.75 end
I would like to fill that missing values with the value of his corresponding gid (the value is always fixed). For example, in the second observation that I showed, there are missing values for the observation in which year is 2002 and gid 136452. I would like to complete the missing values of country_code, latitude and longitude with the ones corresponding to the gid 136452 for any other observation. I also have missing values for variable nactors2 but I do not care at all about it.
If my question is not clear, please let me know.
Diego.
0 Response to Add missing values
Post a Comment