Skip to contents

Create a date_source object as input for derive_var_extreme_dt() and derive_var_extreme_dtm().

Usage

date_source(dataset_name, filter = NULL, date, traceability_vars = NULL)

Arguments

dataset_name

The name of the dataset, i.e. a string, used to search for the date.

filter

An unquoted condition for filtering dataset.

date

A variable providing a date. A date or a datetime can be specified. An unquoted symbol is expected.

traceability_vars

A named list returned by exprs() defining the traceability variables, e.g. exprs(LALVDOM = "AE", LALVSEQ = AESEQ, LALVVAR = "AESTDTC"). The values must be a symbol, a character string, a numeric, or NA.

Value

An object of class date_source.

Examples


# treatment end date from ADSL
trt_end_date <- date_source(
  dataset_name = "adsl",
  date = TRTEDT
)

# lab date from LB where assessment was taken, i.e. not "NOT DONE"
lb_date <- date_source(
  dataset_name = "lb",
  filter = LBSTAT != "NOT DONE" | is.na(LBSTAT),
  date = LBDT
)

# death date from ADSL including traceability variables
death_date <- date_source(
  dataset_name = "adsl",
  date = DTHDT,
  traceability_vars = exprs(
    LALVDOM = "ADSL",
    LALVVAR = "DTHDT"
  )
)