data ONE ; input id visit sbp ; cards ; 101 10 95 101 20 . 101 30 90 102 10 100 102 20 105 102 30 . 103 10 90 103 20 90 103 30 115 104 10 . 104 20 100 104 30 . 104 40 105 ; proc sort data = one out = sorted ; by id visit ;run;
I want LOCF BOCF WOCF for the above data I tried my code but I didn't get the desired output, Please any anyone help me write code?
Here is the code ;
data lf ;
set sorted ;
retain lo;
by id visit ;
if first.id and sbp = . then lo = . ;
else do ;
if id ne . then lo = sbp ;
else sbp = lo ;
end;
run;
Need output like below :
LOCF means Last observation carryforward
BOCF means Baseline observation carryforward (Here baseline visit as 10)
WOCF means Worst observation carryforward
Obs id visit sbp locf bocf wocf 1 1 01 10 95 95 95 95 2 101 20 . 95 95 95 3 101 30 90 90 90 90 4 102 10 100 100 100 100 5 102 20 105 105 105 105 6 102 30 . 105 100 105 7 103 10 90 90 90 90 8 103 20 90 90 90 90 9 103 30 115 115 115 115 10 104 10 . . . 105 11 104 20 100 100 100 100 12 104 30 . 100 . 105 13 104 40 105 105 105 105
... View more