Dear,

I am trying write a loop or program :

- for var1 : replace the missing value (2012) by the value of 2014.
- for var 2: replace the missing values ​​ (2010) by the mean of the 2012 and 2014.

Thank you for your hlep.


the original
Year var1 Var2
2010 2 .
2010 4 .
2010 3 .
2012 . 3
2012 . 2
2012 . 6
2014 5 3
2014 8 8
2014 9 4
What I am looking for
Year var1 Var2
2010 2 3
2010 4 5
2010 3 9
2012 5 3
2012 8 2
2012 9 6
2014 5 3
2014 8 8
2014 9 12