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
Selected Graphs for Panel Data CategoriesHi, I'm new to Stata and I'm trying to get some panel-times series graphs for selected countries. Sp…
Gravity model - PPML fixed-effect estimationDear all, I am doing a study on how Brexit can impact the EU export by using the gravity model. My …
Keeping only unique combination of observations in 2 columnsHi I have observations in two columns. Many of the values get repeated. I would like to keep only un…
Creating a new variable based on the value of other variablesHi all, I have created a categorical variable (values 1 through 5) in excel based on certain charac…
attndHi I am using survey data and I want to use sample weights for estimating attnd and attk after runni…
Subscribe to:
Post Comments (Atom)
0 Response to How do I loop through parts of the observations and impute missing values
Post a Comment