
Derive First or Last Date from Multiple Sources
Source:R/derive_var_extreme_date.R
derive_var_extreme_dt.Rd The
derive_var_extreme_dt()
function has been deprecated in favor of derive_vars_extreme_event().
Add the first or last date from multiple sources to the
dataset, e.g., the last known alive date (LSTALVDT).
Note: This is a wrapper function for the function derive_var_extreme_dtm().
Usage
derive_var_extreme_dt(
dataset,
new_var,
...,
source_datasets,
mode,
subject_keys = get_admiral_option("subject_keys")
)Arguments
- dataset
-
Input dataset
The variables specified by the
subject_keysargument are expected to be in the dataset.- Default value
none
- new_var
-
Name of variable to create
- Default value
none
- ...
-
Source(s) of dates. One or more
date_source()objects are expected.- Default value
none
- source_datasets
-
A named
listcontaining datasets in which to search for the first or last date- Default value
none
- mode
-
Selection mode (first or last)
If
"first"is specified, the first date for each subject is selected. If"last"is specified, the last date for each subject is selected.- Permitted values
"first","last"- Default value
none
- subject_keys
-
Variables to uniquely identify a subject
A list of expressions where the expressions are symbols as returned by
exprs()is expected.- Default value
get_admiral_option("subject_keys")
Details
The following steps are performed to create the output dataset:
For each source dataset the observations as specified by the
filterelement are selected and observations wheredateisNAare removed. Then for each patient the first or last observation (with respect todateandmode) is selected.The new variable is set to the variable or expression specified by the
dateelement.The variables specified by the
set_values_toelement are added.The selected observations of all source datasets are combined into a single dataset.
For each patient the first or last observation (with respect to the new variable and
mode) from the single dataset is selected and the new variable is merged to the input dataset.The time part is removed from the new variable.