derive_var_lstalvdt: Derive Last Known Alive Date

Description Usage Arguments Details Value Author(s) Examples

View source: R/derive_var_lstalvdt.R

Description

[Questioning]

Add the last known alive date (LSTALVDT) to the dataset.

Usage

1
2
3
4
5
6
derive_var_lstalvdt(
  dataset,
  ...,
  source_datasets,
  subject_keys = vars(STUDYID, USUBJID)
)

Arguments

dataset

Input dataset

The variables specified by subject_keys are required.

...

Source(s) of known alive dates. One or more lstalvdt_source() objects are expected.

source_datasets

A named list containing datasets in which to search for the last known alive date

subject_keys

Variables to uniquely identify a subject

A list of quosures where the expressions are symbols as returned by vars() is expected.

Details

The following steps are performed to create the output dataset:

  1. For each source dataset the observations as specified by the filter element are selected. Then for each patient the last observation (with respect to date) is selected.

  2. The LSTALVDT variable is set to the variable specified by the date element. If the date variable is a datetime variable, only the datepart is copied. If the source variable is a character variable, it is converted to a date. If the date is incomplete, it is imputed as specified by the date_imputation element.

  3. The variables specified by the traceability_vars element are added.

  4. The selected observations of all source datasets are combined into a single dataset.

  5. For each patient the last observation (with respect to the LSTALVDT variable) from the single dataset is selected and the new variable is merged to the input dataset.

Value

The input dataset with the LSTALVDT variable added.

Author(s)

Stefan Bundfuss, Thomas Neitmann

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data("dm")
data("ae")
data("lb")
data("adsl")

ae_start <- lstalvdt_source(
  dataset_name = "ae",
  date = AESTDTC,
  date_imputation = "first"
)
ae_end <- lstalvdt_source(
  dataset_name = "ae",
  date = AEENDTC,
  date_imputation = "first"
)
lb_date <- lstalvdt_source(
  dataset_name = "lb",
  date = LBDTC,
  filter = nchar(LBDTC) >= 10
)
adsl_date <- lstalvdt_source(dataset_name = "adsl", date = TRTEDT)

dm %>%
  derive_var_lstalvdt(
    ae_start, ae_end, lb_date, adsl_date,
    source_datasets = list(adsl = adsl, ae = ae, lb = lb)
  ) %>%
  select(USUBJID, LSTALVDT)

# derive last alive date and traceability variables
ae_start <- lstalvdt_source(
  dataset_name = "ae",
  date = AESTDTC,
  date_imputation = "first",
  traceability_vars = vars(
    LALVDOM = "AE",
    LALVSEQ = AESEQ,
    LALVVAR = "AESTDTC"
  )
)

ae_end <- lstalvdt_source(
  dataset_name = "ae",
  date = AEENDTC,
  date_imputation = "first",
  traceability_vars = vars(
    LALVDOM = "AE",
    LALVSEQ = AESEQ,
    LALVVAR = "AEENDTC"
  )
)
lb_date <- lstalvdt_source(
  dataset_name = "lb",
  date = LBDTC,
  filter = nchar(LBDTC) >= 10,
  traceability_vars = vars(
    LALVDOM = "LB",
    LALVSEQ = LBSEQ,
    LALVVAR = "LBDTC"
  )
)

adsl_date <- lstalvdt_source(
  dataset_name = "adsl",
  date = TRTEDT,
  traceability_vars = vars(
    LALVDOM = "ADSL",
    LALVSEQ = NA_integer_,
    LALVVAR = "TRTEDTM"
  )
)

dm %>%
  derive_var_lstalvdt(
    ae_start, ae_end, lb_date, adsl_date,
    source_datasets = list(adsl = adsl, ae = ae, lb = lb)
  ) %>%
  select(USUBJID, LSTALVDT, LALVDOM, LALVSEQ, LALVVAR)

epijim/admiral documentation built on Feb. 13, 2022, 12:15 a.m.