Hi,
I have attached here the code to the dataset that I have and what I am trying to get to but have some difficulty. Essentially, I have a dataset with multiple visits (visit_no) by ID (different IDs have different number of total visits). For each ID, I am trying to fill in the missing values for "result" as "positive" for all visits following a visit in which this variable was already recorded as being "positive". Note: only looking forward when replacing the missing as positive. Note2: if result is negative, leave missing as is.
Many thanks in advance for your help
**
data have;
input ID visit_no result $;
datalines;
1 1 positive
1 2 .
1 3 .
1 4 positive
2 1 negative
2 2 negative
2 3 positive
2 4 .
2 5 .
3 1 .
3 2 negative
3 3 .
4 1 .
4 2 positive
;
run;
data want;
input ID visit_no result $;
datalines;
1 1 positive
1 2 positive
1 3 positive
1 4 positive
2 1 negative
2 2 negative
2 3 positive
2 4 positive
2 5 positive
3 1 .
3 2 negative
3 3 .
4 1 .
4 2 positive
;
run;
... View more