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!
Related Posts with How do I loop through parts of the observations and impute missing values
2SLS For BeginnersI am would love some help understanding how to run a 2SLS. I am replicating a table and first ran an…
Negative scale value using fixed effects quantile regression xtqregI have individual-level panel wealth-at-age data with 4600 observations on 350 individuals. Because …
Export matrix to Word with asdocx after the predict commandProf River Huang asked the following question Dear Attaullah, Is it possible to put the results …
Can the attenuation bias of a demeaned dependent variable be solved by an control function approach?I recently demeaned my dependent variable by a group interaction. Mainly because simply adding them …
Comparing population and sample age and sex distributionHi all, I am not so sure if my logic for the code is right or wrong. I have to check if the age and…
Subscribe to:
Post Comments (Atom)
0 Response to How do I loop through parts of the observations and impute missing values
Post a Comment