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
Invalid nameHello everyone, I would like to kindly ask the community for a help. I use STATA 16, Windows 10. Whe…
Exporting table into LatexI am trying to produce the share of police stops per NYC borough in a table, then export it from Sta…
rdrobust questionI am interested in having my rdrobust regression have different bandwidths on each side. I put the f…
Question: how to compute a variable value based on its last value in a panel datasetDear All, I am trying to do the calculation illustrated in Excel with Stata. Specifically, I would …
Suppressing the iterlog with mlogit for Stata 14Hello, I was looking to suppress the iterlog when running mlogit. I'm aware of set iterlog, but ran…
Subscribe to:
Post Comments (Atom)
0 Response to How do I loop through parts of the observations and impute missing values
Post a Comment