Hi - I am hoping someone will be able to help me with panel data! I am trying to create a time-varying variable (i.e., time between assessment points).
I am able to generate 0 for assessment #1 using: replace Time between assessment = 0 if Assessment#==1, but am not sure how to get Stata to calculate the difference in ages (the cells in bold & italics).
Thanks in advance for your suggestions!
I am able to generate 0 for assessment #1 using: replace Time between assessment = 0 if Assessment#==1, but am not sure how to get Stata to calculate the difference in ages (the cells in bold & italics).
ID | Score | Assessment # | Age (months) | Time between assessment | |
1 | 20 | 1 | 18 | 0 | |
2 | 30 | 1 | 20 | 0 | |
2 | 35 | 2 | 26 | *Should be 6 (26-20 mos.) | |
3 | 15 | 1 | 24 | 0 | |
4 | 7 | 1 | 30 | 0 | |
5 | 10 | 1 | 26 | 0 | |
5 | 16 | 2 | 30 | *Should be 4 (30-26 mos.) | |
5 | 18 | 3 | 37 | *Should be 7 (37-30 mos.) | |
6 | 40 | 1 | 21 | 0 |
Comment