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
Is there a way to get overall effects for a KHB decomposition when I have a categorical key variable?Dear all, I am currently running a KHB mediation analysis with a continuous DV (cognitive developmen…
Indicate Fixed Effects in esttabHello Statalist users, I have a question regarding the esttab command. More precisely, I run my reg…
Form a text string of scalar product of two macrosHi Statalist users, I need advice on the following problem. Suppose I have two macros local b "b1…
Tag observations occuring within a time frameHi, I'm working with diagnostic labdata and I'd like to count how many times a person has been test…
Bug in local variable with string?Hello, I recently came across something strange which I can't seem to understand. It concerns the w…
Subscribe to:
Post Comments (Atom)
0 Response to How do I loop through parts of the observations and impute missing values
Post a Comment