BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
michtka
Fluorite | Level 6

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.

         .            .

1 ACCEPTED SOLUTION

Accepted Solutions
michtka
Fluorite | Level 6

...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;

View solution in original post

1 REPLY 1
michtka
Fluorite | Level 6

...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;

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 714 views
  • 0 likes
  • 1 in conversation