Skip to contents

Define and create age categories either by age interval or specified age categories. How to define the age categories in EXTRA column in Access is shown in the example below. This function is only applicable in the filegroup table. The input dataset must be in data.table format if using the function outside Access. Convert dataset to data.table with data.table::setDT(DF).

Age categories can be specified as follows:

  • Specific interval eg. every 5 years. Interval with odd numbers will use minimum age of 0 and maximum age is 85+, while even number uses maximum age of 80+ eg AgeCat(5).

  • Varied intervals where lower bound need to be specified eg. 0, 19, 45, 65, 80 for age categories of 0-18,19-44,45-64,65-79, 80+ eg. AgeCat(0, 19, 45, 65, 80).

  • Mix between specific and varied intervals with [x] eg. 0, 3, 10, 20, 30, 40, 55+. Here the first 3 groups has varied intervals and followed by specified interval of 10 year eg. AgeCat(0, 3, 10, [10], 40, 55). However, multiple use of [x] in a call will fail eg. AgeCat(0, [5], 30, [10], 60, 75).

Usage

find_age_category(dt = NULL, interval = NULL)

Arguments

dt

Dataset

interval

Age interval

See also

Examples

# How to write it in column EXTRA in Access:

# AgeCat(5) #Specific interval. Every 5 years
# AgeCat(0,19,45,65,80) #Varied intervals with each group lower bound
# AgeCat(0, 3, 10, [10], 40, 55) #Varied and specific interval (10 years)