Hello,
I am working with a large panel dataset (NLSY79 if that means anything to you) and I am trying to clean up a variable capturing the highest grade of education completed by the individual (HGC). Below is a table where I provide an example of the variable I am working with, HGC, and a variable to illustrate the problem that occurs when I carry forward missing values: HGC_Carried.
However, the problem I am running into is highlighted in red for ID #2. When I carry forward the values, ID 2 ends up with HGC of 13 for years 2005-2009, but then switches to 12 for 2010-2015. I need a way to code this such that the highest value of the variable will carry forward and replace any lesser values that occur after it. Correctly coded would show HGC =13 for years of ID# 2.
I hope that makes sense. Please let me know if you have any questions and thank you for your time and assistance.
Joe
I am working with a large panel dataset (NLSY79 if that means anything to you) and I am trying to clean up a variable capturing the highest grade of education completed by the individual (HGC). Below is a table where I provide an example of the variable I am working with, HGC, and a variable to illustrate the problem that occurs when I carry forward missing values: HGC_Carried.
However, the problem I am running into is highlighted in red for ID #2. When I carry forward the values, ID 2 ends up with HGC of 13 for years 2005-2009, but then switches to 12 for 2010-2015. I need a way to code this such that the highest value of the variable will carry forward and replace any lesser values that occur after it. Correctly coded would show HGC =13 for years of ID# 2.
I hope that makes sense. Please let me know if you have any questions and thank you for your time and assistance.
Joe
| ID | Year | HGC | HGC_Carried |
| 1 | 2005 | 12 | 12 |
| 1 | 2006 | 12 | 12 |
| 1 | 2007 | 12 | 12 |
| 1 | 2008 | . | 12 |
| 1 | 2009 | . | 12 |
| 1 | 2010 | 14 | 14 |
| 1 | 2011 | 15 | 15 |
| 1 | 2012 | . | 15 |
| 1 | 2013 | 16 | 16 |
| 1 | 2014 | . | 16 |
| 1 | 2015 | . | 16 |
| 2 | 2005 | . | 13 |
| 2 | 2006 | 13 | 13 |
| 2 | 2007 | 13 | 13 |
| 2 | 2008 | 13 | 13 |
| 2 | 2009 | . | 12 |
| 2 | 2010 | 12 | 12 |
| 2 | 2011 | 12 | 12 |
| 2 | 2012 | . | 12 |
| 2 | 2013 | . | 12 |
| 2 | 2014 | . | 12 |
| 2 | 2015 | . | 12 |
| 3 | 2005 | 11 | 11 |
| 3 | 2006 | 12 | 12 |
| 3 | 2007 | 13 | 13 |
| 3 | 2008 | 14 | 14 |
| 3 | 2009 | . | 14 |
| 3 | 2010 | . | 14 |
| 3 | 2011 | 17 | 17 |
| 3 | 2012 | 18 | 18 |
| 3 | 2013 | 19 | 19 |
| 3 | 2014 | . | 19 |
| 3 | 2015 | 21 | 20 |

Comment