Dear Statalist,

My data looks like this
id hypertension visit
1 . 1
1 0 2
2 . 1
2 . 2
2 1 3
3 . 1
4 . 1
5 0 1
5 1 2
5 . 3
(hypertension 1=yes;0=no; . =missing value)(Every ID had 1-3 visits)
I'm trying to impute all missing values according to the following rule.
"If an ID has hypertension, this ID must have hypertension in the future."
ex: ID1 didn't have hypertension on his second visit, so he didn't have hypertension on his first visit either.
ex: ID5 had hypertension on his second visit, so he must had hypertension on his third visit as well.

There are hundreds of ID in my data, so I'm trying to use loop to solve the problem.
I found something like increment might be related.
Can anyone give me more information?
Thanks!