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
Thought Experiment re: Logistic RegressionDear all, I would like to ask your advice regarding logistic regression. In my study, I am looking…
correct marginal effects after ivprobitDear all, Couple of recent posts point out difficulties obtaining the marginal effects after IVprobi…
Data manipulation: Calculating the mean of two or more numbers and putting it back into the data setDear Statalists, i generally want to calculate the AAR from AR. In order to do so i have generated …
Loops with generateHi all, I am trying to generate a dummy variable identifying missings values for a long list of var…
Help with generate dummyArray Hi! This is a part of my data. I have 24 countries (land) and I want to make two dummy's for …
Subscribe to:
Post Comments (Atom)
0 Response to How do I loop through parts of the observations and impute missing values
Post a Comment