Initial code, developed to hikuo and moddified for you, missing visit is imputed as the LOCF, but the baseline is not carried forward , i.e week2 if it is missing reamining missing in subject2, and week2, week4 willremaining missing in subject3: proc format; value $seq 'baseline'=1 'week2'=2 'week4'=3 'week8'=4 'week12'=5 ; value seq 1='baseline' 2='week2' 3='week4' 4='week8' 5='week12' ; run; data new; length subjid $8 day $10 value 8; input subjid day value; datalines; 1 baseline 10 1 week2 12 1 week4 14 1 week8 16 1 week12 12 2 baseline 10 2 week4 12 3 baseline 10 3 week8 4 ; data new1; set new; _day=put(day,$seq.); run; data new1; set new; _day=put(day,$seq.); run; data want; set new1; by subjid; set new1(firstobs=2 keep=_day rename=_day=__day) new1(obs=1 drop=_all_); if not last.subjid then do _i=_day to __day-1; day=put(_i,seq.); if not missing(value) then output; if _day = 1 then call missing(value); end; else do _i=_day to 5; day=put(_i,seq.); output; end; drop _:; run; this is the dataset: 1 1 baseline 10 2 1 week2 12 3 1 week4 14 4 1 week8 16 5 1 week12 12 6 2 baseline 10 7 2 week4 12 8 2 week8 12 9 2 week12 12 10 3 baseline 10 11 3 week8 4 12 3 week12 4 Now, my problem, is that only I am interested to impute the last visit, i.e i need to ridd off week8, because it was a visit missing in the original dataset, in with this condition, because it is not a last visit, it will remain missing...then my finaldataset , modifying the above code , have to be like that: 1 1 baseline 10 2 1 week2 12 3 1 week4 14 4 1 week8 16 5 1 week12 12 6 2 baseline 10 7 2 week4 12 8 2 week12 12 9 3 baseline 10 10 3 week8 4 11 3 week12 4 Thnak you.
... View more