Dear Colleagues,
I am processing a survey panel data of children and youth that have several waves of interviews. A few variables I am interested in are collected only in one or two waves and for children at certain ages. I would like to identify the first available/non-missing values of these variables and assign them as new variables for the whole group. I would also like to do the same for the last non-missing values.
Like in the table below, the variable var1 is only available in certain waves. I would like to create new variables: var1_1st for first non-missing values, and var1_last for last non-missing values. Is there any way I can get this done efficiently? Thanks.
I am processing a survey panel data of children and youth that have several waves of interviews. A few variables I am interested in are collected only in one or two waves and for children at certain ages. I would like to identify the first available/non-missing values of these variables and assign them as new variables for the whole group. I would also like to do the same for the last non-missing values.
Like in the table below, the variable var1 is only available in certain waves. I would like to create new variables: var1_1st for first non-missing values, and var1_last for last non-missing values. Is there any way I can get this done efficiently? Thanks.
child | wave | var1 | var1_1st | var1_last |
1 | 1 | . | 20 | 30 |
1 | 2 | 20 | 20 | 30 |
1 | 3 | 30 | 20 | 30 |
1 | 4 | . | 20 | 30 |
2 | 1 | . | 34 | 32 |
2 | 3 | 34 | 34 | 32 |
2 | 4 | 32 | 34 | 32 |
Comment