Hi everyone, I need to imputed the next VISIT record (only the next one) using LOCF when the AE stop, i.e
VISIT 01DEC2008 for subject1 and VISIT 30JAN2009 for subject 2, tha at the moment are missing.
data have;
informat VISIT date9. START date9. STOP date9.;
input SUBJID VISIT START STOP;
format VISIT date9. START date9. STOP date9.;
cards;
1 02APR2008 07NOV2008 26NOV2008
1 07APR2008 07NOV2008 26NOV2008
1 12MAY2008 07NOV2008 26NOV2008
1 19MAY2008 07NOV2008 26NOV2008
1 30JUN2008 07NOV2008 26NOV2008
1 01JUL2008 07NOV2008 26NOV2008
1 07JUL2008 07NOV2008 26NOV2008
1 07AUG2008 07NOV2008 26NOV2008
1 29SEP2008 07NOV2008 26NOV2008
1 13OCT2008 07NOV2008 26NOV2008
1 20OCT2008 07NOV2008 26NOV2008
1 01DEC2008 . .
1 22FEB2009 . .
2 27NOV2008 06DEC2008 01JAN2009
2 08DEC2008 06DEC2008 01JAN2009
2 22DEC2008 06DEC2008 01JAN2009
2 30JAN2009 . .
2 30MAR2009 . .
;
run;
Thanks,
Vi.
. .
...adding extra variables (x1 x2) using LAG function is an option.
data have2;
set have;
x1=lag(start);
x2=lag(stop);
output;
run;
data want;
set have2;
if visit > stop and (x1 or x2) ne . then do;
start=x1;
stop=x2;
end;
run;
...adding extra variables (x1 x2) using LAG function is an option.
data have2;
set have;
x1=lag(start);
x2=lag(stop);
output;
run;
data want;
set have2;
if visit > stop and (x1 or x2) ne . then do;
start=x1;
stop=x2;
end;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.