SAMPLE DATA:
Rules for var1:
if var1 is missing, fill with previous value
if var1 at time t is 3, all future var1 values are set to 3 unless there is a 4, which stays a 4
if var1 is missing after a 4, remove that row
DESIRED OUTPUT:
Code:
input person time var1 1 1 1 1 2 2 1 3 . 1 4 3 1 5 1 1 6 4 2 1 2 2 2 2 2 3 . 2 4 . 2 5 3 2 6 3 3 1 3 3 2 4 3 3 . 3 4 . 3 5 . 3 6 . end
if var1 is missing, fill with previous value
if var1 at time t is 3, all future var1 values are set to 3 unless there is a 4, which stays a 4
if var1 is missing after a 4, remove that row
DESIRED OUTPUT:
Code:
input person time var1 1 1 1 1 2 2 1 3 2 1 4 3 1 5 3 1 6 4 2 1 2 2 2 2 2 3 2 2 4 2 2 5 3 2 6 3 3 1 3 3 2 4 end
Comment