I want to use LOCF to impute missing values, but the missing visits are not present in the dataset.
In this case, how do I check the missing visits and set the value to missing value first, and then use retain to do LOCF?
data visit;
input ID $ avisitn result;
datalines;
A 0 4.1
A 1 3.9
A 2 4.3
A 4 5.0
A 8 4.5
A 12 5.1
A 16 5.3
A 18 4.9
A 20 4.7
B 0 4.2
B 1 3.7
B 2 4.4
B 4 5.2
B 12 4.5
B 16 5.2
B 18 4.8
B 20 4.9
C 0 4.6
C 1 4.9
C 2 5.3
C 8 5.5
C 16 5.6
C 18 5.9
C 20 5.7
;
run;
/* avisitn is 0, 1, 2, 4, 8, 12, 16, 18, 20* /
/* A has all visits, B misses avisitn 8, C misses avisit 4 & 12 */
... View more