
Query to add the age of the individuals at a certain date
Source:R/addDemographicsQuery.R
addAgeQuery.Rd
`r lifecycle::badge("experimental")` Same as `addAge()`, except query is not computed to a table.
Usage
addAgeQuery(
x,
indexDate = "cohort_start_date",
ageName = "age",
ageGroup = NULL,
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
missingAgeGroupValue = "None"
)
Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the age.
- ageName
Name of the new column that contains age.
- ageGroup
List of age groups to be added.
- ageMissingMonth
Month of the year assigned to individuals with missing month of birth. By default: 1.
- ageMissingDay
day of the month assigned to individuals with missing day of birth. By default: 1.
- ageImposeMonth
Whether the month of the date of birth will be considered as missing for all the individuals.
- ageImposeDay
Whether the day of the date of birth will be considered as missing for all the individuals.
- missingAgeGroupValue
Value to include if missing age.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 |>
addAgeQuery()
#> # Source: SQL [?? x 5]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date age
#> <int> <int> <date> <date> <int>
#> 1 2 6 1937-09-06 1940-04-04 1
#> 2 2 10 1946-03-13 1948-09-04 26
#> 3 2 1 1964-11-04 1984-08-21 6
#> 4 3 7 1998-11-28 1999-12-23 50
#> 5 1 4 1949-05-17 1949-11-02 39
#> 6 1 3 1921-07-09 1924-02-13 14
#> 7 1 5 1946-03-10 1954-12-14 20
#> 8 2 9 1981-05-19 1996-07-24 25
#> 9 2 8 1939-03-08 1939-09-14 5
#> 10 1 2 1948-09-29 1954-07-07 4
mockDisconnect(cdm = cdm)
# }