Hello everyone,
my data set contains 8,232 students (IDaluno) in a panel structure with T=5 (wave).
My dependent variable is test scores (Zprofic_mat) and the data are NOT completely balanced. See below that for the students 13648, 13649 and 13651, I have all the 5 test scores. But for the 13650, the test scores in T=1 and T=3 are missing.
I will estimate a value-added model. For this reason, I create the variable ZMat_LF which should import the first test score in the panel.
The command above works fine for 13648, 13649 and 13651, but not for the 13650. So, I need a code now that in case of missing by ZMat_LF, than it replaces the test scores from T=2. If still missing, then T=3 and so on.
Does anyone have any idea of how can I create that?
Any advice would be highly appreciated!
Thanks in advance.
my data set contains 8,232 students (IDaluno) in a panel structure with T=5 (wave).
My dependent variable is test scores (Zprofic_mat) and the data are NOT completely balanced. See below that for the students 13648, 13649 and 13651, I have all the 5 test scores. But for the 13650, the test scores in T=1 and T=3 are missing.
I will estimate a value-added model. For this reason, I create the variable ZMat_LF which should import the first test score in the panel.
Code:
generate ZMat_LF = Zprofic_mat if wave==1 bysort IDaluno (wave): replace ZMat_LF=ZMat_LF[1] . list IDaluno wave Zprofic_mat ZMat_LF in 1/20 +---------------------------------------+ | IDaluno wave Zprofic~t ZMat_LF | |---------------------------------------| 1. | 13648 1 .0793902 .0793902 | 2. | 13648 2 -.6800427 .0793902 | 3. | 13648 3 -1.84665 .0793902 | 4. | 13648 4 -2.035958 .0793902 | 5. | 13648 5 -1.590294 .0793902 | |---------------------------------------| 6. | 13649 1 -1.98832 -1.98832 | 7. | 13649 2 -.2193679 -1.98832 | 8. | 13649 3 -1.813179 -1.98832 | 9. | 13649 4 -.8301591 -1.98832 | 10. | 13649 5 -.7455558 -1.98832 | |---------------------------------------| 11. | 13650 2 .1301447 . | 12. | 13650 4 .8231199 . | 13. | 13650 5 1.288692 . | 14. | 13651 1 .3280044 .3280044 | 15. | 13651 2 .4950224 .3280044 | |---------------------------------------| 16. | 13651 3 .1835145 .3280044 | 17. | 13651 4 -.291254 .3280044 | 18. | 13651 5 .4207084 .3280044 | 19. | 13652 1 .4693756 .4693756 | 20. | 13652 2 .0952681 .4693756 | +---------------------------------------+
Does anyone have any idea of how can I create that?
Any advice would be highly appreciated!
Thanks in advance.
Comment