
Query to add the age of the individuals at a certain date
Source:R/addDemographicsQuery.R
addAgeQuery.RdSame 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,
ageUnit = "years",
missingAgeGroupValue = "None"
)Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the demographics characteristics.
- ageName
Age variable name.
- ageGroup
if not NULL, a list of ageGroup vectors.
- ageMissingMonth
Month of the year assigned to individuals with missing month of birth.
- ageMissingDay
day of the month assigned to individuals with missing day of birth.
- ageImposeMonth
TRUE or FALSE. Whether the month of the date of birth will be considered as missing for all the individuals.
- ageImposeDay
TRUE or FALSE. Whether the day of the date of birth will be considered as missing for all the individuals.
- ageUnit
Unit for age it can either be 'years', 'months' or 'days'.
- missingAgeGroupValue
Value to include if missing age.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addAgeQuery()
#> # Source: SQL [?? x 5]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date age
#> <int> <int> <date> <date> <int>
#> 1 2 10 1978-06-03 2007-06-06 3
#> 2 3 6 1951-02-06 1968-10-06 10
#> 3 2 1 1927-04-29 1933-11-13 8
#> 4 2 3 1978-06-21 1978-07-13 44
#> 5 2 2 1947-12-05 1956-08-07 24
#> 6 2 4 1939-11-07 1942-08-10 22
#> 7 2 5 1970-04-10 1971-02-25 21
#> 8 1 8 1974-09-03 1975-05-20 15
#> 9 2 9 1958-05-16 1966-07-09 29
#> 10 3 7 1980-03-05 1981-11-29 6
# }