Linked In Icon Twitter Icon Facebook Icon

"very actual topics leading to interesting and open discussion"

GSK

PhUSE Wiki

Locf 

Wiki content first added by: Daniel Boisvert

  
LOCF or Last Observation Carried Forward is an imputation technique that not surprisingly, carries the last assessed value forward to visits where a value is missing.

Last Observation Carried Forward 

Section content first added by: Daniel Boisvert


DATA lab;
  INPUT usubjid $ lbtestcd $ avisitn aval;
  DATALINES;
101-1001 WBC 0 10
101-1001 WBC 1 20
101-1001 WBC 2 30
101-1001 WBC 3 .
101-1001 WBC 4 .
101-1001 RBC 0 100
101-1001 RBC 1 200
101-1001 RBC 2 300
101-1001 RBC 3 .
101-1001 RBC 4 400
;
RUN;


PROC SORT DATA=lab;
  BY usubjid lbtestcd avisitn;
RUN;

************************************************;
**** When using RETAIN be absolutely sure   ****;
****  not to drag records between patients  ****;
****  or testcds.                           ****;
****                                        ****;
**** In this example keep aval and avallocf ****;
**** separate to show what is going on.     ****;
**** Generally, aval would be overwritten   ****;
**** with the LOCFed values.                ****;
************************************************;
DATA locf;
  LENGTH dtype $15;
  RETAIN retaval;
  SET lab;
  BY usubjid lbtestcd avisitn;

  IF FIRST.lbtestcd THEN retaval=.;

  IF aval NE . THEN retaval=aval;
   
  IF aval=. THEN DO;
    avallocf=retaval;
    dtype='LOCF';
  END;
  ELSE avallocf=aval;
 

  LABEL dtype = 'Derivation Type';
RUN;

Contibute to this Wiki

Register You need to register to contribute to this Wiki.

Login If you are already regsitered please login.