Derivation of LOCF and WOCF

Introduction

In most of the clinical trial analysis, there are missing data due to dropouts. The reasons can be non-informative(for example subject moves to another city with his or her family) and informative(may be related to treatment assignment or outcomes). Since we are not sure whether the missing data is due to informative or non informative reasons we cannot ignore the dropouts. So in such cases we can make use of LOCF or WOCF. Both the imputation methods can be used when repeated measures have been taken per subject by timepoint. For LOCF, last observed non missing value is used to fill missing values at a later point in the study. For WOCF, worst value(specified in the SAP) is used. Before deriving the locf records, we need to have the baseline and post baseline flags derived.

Input Data:

Consider the following dataset having laboratory details from a study having single treatment group Treatment A. We can see that the aval value is missing for usubjid ZYX-01-101

Algorithm:

a. Creating both the LOCF and WOCF records in the same datastep.

1.Sort the data by date/visit number within the parameter 2. Use the sorted dataset in do until and set the last non missing collected post baseline value as LOCF for each param and output as new record. For both the records we do not need to carry forward the baseline values.

b. Use different datasteps

LOCF

  1. Sort the data by date/visit number within the parameter
  2. Create a dataset with only the last non-missing (aval ne .) collected value (–seq ne .) within the parameter
  3. Append this dataset to the original dataset.

WOCF

  1. Here we consider the largest value among all visits as the WOCF. Sort the data by date/visit number and aval within the parameter.
  2. Create a dataset with only the last non-missing (aval ne .) collected value (–seq ne .) within the parameter.
  3. Append this dataset to the original dataset.

SAS Code

a.

proc sort data =visit; 
  by usubjid paramn avisitn; 
run;

data final; 
  do i = 1 by 1 until(last.param); 
  set visit; 
  by usubjid param avisitn; 
  output; 
  locf0 = lag(aval); 
  pbfl0 = lag(pbfl); 
  if not missing(locf0) and pbfl0 = "Y" then locf = locf0; 
  if cmiss(wocf,locf) and pbfl0 = "Y" then wocf = max(wocf,locf);
  if missing(aval) and pbfl eq "Y" then do; 
  aval = locf;
  *creating new record; 
  dtype = "LOCF"; 
  output; 
  aval = wocf;
  *creating new record; 
  dtype= "WOCF"; 
  output; end; 
  dtype = ""; 
  end; 
  drop locf0 pbfl0; 
run;

b.

LOCF

proc sort data =visit; 
  by usubjid paramn avisitn; 
run;

data final1; 
  set visit (where = (aval ne . and lbseq ne . and \~missing(pbfl)); 
  by usubjid param avisitn/adt; 
  if last.paramn then do; 
  dtype = 'LOCF';
  output; 
  end; 
run;

proc sql noprint; 
  create table miss as select \* from visit where missing(aval); 
quit;

proc sort data=final1(keep=usubjid param aval dtype); 
  by usubjid param; 
run; 

proc sort data=miss; 
  by usubjid param; 
run;

data final2; 
  merge miss(in=a) final1(in=b); 
  by usubjid param; 
  if a; 
run;

data final; 
  set visit final2; 
  proc sort; 
  by usubjid paramn adt; 
run;

WOCF

proc sort data = visit;
by usubjid paramn aval avisitn;
run;

data final1;
set visit (where = (aval ne . and lbseq ne . and ~missing(pbfl))); 
by usubjid paramn aval avisitn ; 
if last.paramn then do; 
dtype = 'WOCF';
output;
end;
run;

proc sql noprint; 
create table miss as select * from visit where missing(aval); 
quit;

proc sort data=final1(keep=usubjid param aval dtype); 
by usubjid param; 
run; 

proc sort data=miss; 
by usubjid param;
run; 

data final2; 
merge miss(in=a) final1(in=b);
by usubjid param; 
if a;
run; 

data final; 
set visit final2; 
proc sort;
by usubjid paramn adt;
run;

Output:

a

b

LOCF

WOCF

back