diff --git a/.gitignore b/.gitignore index 47519dd8..4b9633af 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .Ruserdata *.DS_Store docs/ +.claude/ \ No newline at end of file diff --git a/NAMESPACE b/NAMESPACE index 6ae6fa9c..b2994ebe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -36,6 +36,8 @@ export(age_cat_fun) export(binge_drinker_fun) export(bmi_fun) export(bmi_fun_cat) +export(calculate_pct_time) +export(categorize_pct_time) export(check_worksheet) export(diet_score_fun) export(diet_score_fun_cat) @@ -45,6 +47,7 @@ export(food_insecurity_der) export(if_else2) export(immigration_fun) export(is_equal) +export(load_schema) export(low_drink_long_fun) export(low_drink_score_fun) export(low_drink_score_fun1) @@ -54,8 +57,6 @@ export(multiple_conditions_fun1) export(multiple_conditions_fun2) export(pack_years_fun) export(pack_years_fun_cat) -export(pct_time_fun) -export(pct_time_fun_cat) export(rec_with_table) export(resp_condition_fun1) export(resp_condition_fun2) @@ -63,6 +64,7 @@ export(resp_condition_fun3) export(set_data_labels) export(smoke_simple_fun) export(time_quit_smoking_fun) +importFrom(dplyr,case_when) importFrom(dplyr,do) importFrom(dplyr,rowwise) importFrom(dplyr,select) diff --git a/R/percent-time-canada.R b/R/percent-time-canada.R index 9966e18c..258ac76f 100644 --- a/R/percent-time-canada.R +++ b/R/percent-time-canada.R @@ -1,50 +1,43 @@ -#' @title Percent time in Canada -#' -#' @description This function creates a derived variable (pct_time_der) that -#' provides an estimated percentage of the time a person's life was spent in -#' Canada. -#' -#' @param DHHGAGE_cont continuous age variable. -#' -#' @param SDCGCBG whether or not someone was born in Canada (1 - born in Canada, -#' 2 - born outside Canada) -#' -#' @param SDCGRES how long someone has lived in Canada. Note: in the PUMF CCHS -#' datasets, this is a categorical variable with two categories (1 - 0-9 years; -#' 2 - 10+ years). -#' -#' @note Since SDCGRES is a categorical variable measuring length of time, we've -#' set midpoints in the function. A respondent identified as being in Canada -#' for 0-9 years is assigned a value of 4.5 years, and someone who has been in -#' Canada for over 10 years is assigned a value of 15 years. -#' -#' @return Numeric value between 0 and 100 that represents -#' percentage of a respondent's time in Canada +#' @title Calculate percent time in Canada +#' +#' @description Calculates the percentage of a respondent's life spent in +#' Canada. Used by pct_time_der for both PUMF and master databases. The +#' worksheet maps different feeder variables for each database type, but +#' the calculation is the same: for respondents born outside Canada, +#' percent time = years in Canada / age * 100. +#' +#' For PUMF data, the categorical time-in-Canada variable (SDCGRES) is +#' converted to continuous midpoints upstream via the SDCGRES_cont intermediate +#' variable in variable_details.csv (1 = 4.5 years, 2 = 15 years). For master +#' data, continuous years (SDCDRES) are passed directly. +#' +#' @param age continuous age variable. +#' @param born_in_canada whether or not someone was born in Canada +#' (1 - born in Canada, 2 - born outside Canada). +#' @param years_in_canada continuous years in Canada. For PUMF data, this is +#' derived from the categorical SDCGRES via midpoint conversion in +#' variable_details.csv. For master data, this is the actual continuous +#' years from SDCDRES. +#' +#' @return Numeric value between 0 and 100 that represents percentage of a +#' respondent's time in Canada. Returns \code{tagged_na("b")} for invalid or +#' missing inputs. #' #' @examples -#' # Using pct_time_fun() to create percent time values between CCHS cycles -#' # pct_time_fun() is specified in variable_details.csv along with the CCHS -#' # variables and cycles included. -#' -#' # To transform pct_time_der across cycles, use rec_with_table() for each CCHS -#' # cycle and specify pct_time_der, along with age (DHHGAGE_cont), whether or -#' # not someone was born in Canada (SDCGCBG), how long someone has lived in -#' # Canada (SDCGRES). Then by using merge_rec_data(), you can combine -#' # pct_time_der across cycles -#' +#' # Using rec_with_table() across CCHS cycles (PUMF) #' library(cchsflow) #' pct_time2009_2010 <- rec_with_table( #' cchs2009_2010_p, c( #' "DHHGAGE_cont", "SDCGCBG", -#' "SDCGRES", "pct_time_der" +#' "SDCGRES_cont", "pct_time_der" #' ) #' ) #' head(pct_time2009_2010) #' #' pct_time2011_2012 <- rec_with_table( -#' cchs2011_2012_p, c( +#' cchs2011_2012_p, c( #' "DHHGAGE_cont", "SDCGCBG", -#' "SDCGRES", "pct_time_der" +#' "SDCGRES_cont", "pct_time_der" #' ) #' ) #' tail(pct_time2011_2012) @@ -53,97 +46,100 @@ #' head(combined_pct_time) #' tail(combined_pct_time) #' -#' # Using pct_time_fun() to generate a value for percent time spent in Canada -#' # with user inputted values Let's say you are 27 years old who was born -#' # outside of Canada and have been living in Canada for less than 10 years. -#' # Your estimated percent time spent in Canada can be calculated as follows: +#' # Scalar usage (pass continuous years directly) +#' calculate_pct_time(age = 27, born_in_canada = 2, years_in_canada = 4.5) #' -#' pct_time <- pct_time_fun(DHHGAGE_cont = 27, SDCGCBG = 2, SDCGRES = 1) -#' -#' print(pct_time) +#' # Vector usage +#' calculate_pct_time( +#' age = c(27, 40, 35), +#' born_in_canada = c(2, 1, 2), +#' years_in_canada = c(4.5, 4.5, 15) +#' ) #' @export -pct_time_fun <- - function(DHHGAGE_cont, SDCGCBG, SDCGRES) { - if (is_equal(SDCGCBG, 1)) { - return(100) - } - DHHGAGE_cont <- if_else2(DHHGAGE_cont > 0, DHHGAGE_cont, - return(tagged_na("b"))) - SDCGRES <- if_else2(SDCGRES == 1, 4.5, - if_else2(SDCGRES == 2, 15, return(tagged_na("b")))) - - if_else2(SDCGCBG == 2, (SDCGRES / DHHGAGE_cont * 100), tagged_na("b")) - } +calculate_pct_time <- function(age, born_in_canada, years_in_canada) { + result <- dplyr::case_when( + born_in_canada == 1 ~ 100, + born_in_canada == 2 & age > 0 & !is.na(years_in_canada) ~ + years_in_canada / age * 100, + TRUE ~ tagged_na("b") + ) + # Output validation: values outside [0, 100] indicate inconsistent inputs + # (e.g., years_in_canada > age). Valid range: 0-100. + # Documentation-only boundaries in variable_details; enforced here. + dplyr::case_when( + is.na(result) ~ result, + result < 0 | result > 100 ~ tagged_na("b"), + TRUE ~ result + ) +} -#' @title Categorical percent time in Canada -#' -#' @description This function creates a categorical derived variable -#' (pct_time_der_cat10) that categorizes the derived percent time in Canada -#' variable (pct_time_der). -#' -#' @details The percent time in Canada provides an estimated percentage of the -#' time a person's life was spent in Canada.The categorical percent time in +#' @title Categorize percent time in Canada +#' +#' @description Categorizes the derived percent time in Canada variable +#' (pct_time_der) into 10 percent intervals for pct_time_der_cat10. +#' +#' @details The percent time in Canada provides an estimated percentage of the +#' time a person's life was spent in Canada. The categorical percent time in #' Canada divides the continuous value into 10 percent intervals. -#' -#' pct_time_der_cat10 uses the derived variable pct_time_der. pct_time_der uses -#' various variables that have been transformed by cchsflow (see documentation -#' on pct_time_der). In order to categorize percent time in Canada across CCHS +#' +#' pct_time_der_cat10 uses the derived variable pct_time_der. pct_time_der uses +#' various variables that have been transformed by cchsflow (see documentation +#' on pct_time_der). In order to categorize percent time in Canada across CCHS #' cycles, the variables must be transformed and harmonized. #' #' @param pct_time_der derived continuous percent time in Canada. -#' See \code{\link{pct_time_fun}} for documentation on how variable was derived. -#' -#' @return value for categorical percent time in Canada using pct_time_der -#' variable. +#' See \code{\link{calculate_pct_time}} for documentation on how variable was +#' derived. #' -#' @examples -#' # Using pct_time_fun_cat() to create categorical percent time values -#' # between CCHS cycles. -#' # pct_time_fun_cat() is specified in variable_details.csv along with the CCHS -#' # variables and cycles included. -#' -#' # To transform pct_time_der_cat10 across cycles, use rec_with_table() for -#' # each CCHS cycle. -#' # Since pct_time_der is a derived variable, you will have to specify the -#' # variables that are derived from it. -#' # Then by using merge_rec_data(), you can combine pct_time_der_cat10 across -#' # cycles. +#' @return Character value for categorical percent time in Canada ("1" through +#' "10"), "NA(a)" for not applicable, or "NA(b)" for missing/invalid inputs. #' +#' @examples +#' # Using rec_with_table() across CCHS cycles #' library(cchsflow) #' pct_time_cat2009_2010 <- rec_with_table( #' cchs2009_2010_p, c( #' "DHHGAGE_cont", "SDCGCBG", -#' "SDCGRES", "pct_time_der", "pct_time_der_cat10" +#' "SDCGRES_cont", "pct_time_der", "pct_time_der_cat10" #' ) #' ) #' head(pct_time_cat2009_2010) #' #' pct_time_cat2011_2012 <- rec_with_table( -#' cchs2011_2012_p, c( +#' cchs2011_2012_p, c( #' "DHHGAGE_cont", "SDCGCBG", -#' "SDCGRES", "pct_time_der", "pct_time_der_cat10" +#' "SDCGRES_cont", "pct_time_der", "pct_time_der_cat10" #' ) #' ) #' tail(pct_time_cat2011_2012) #' -#' combined_pct_time_cat <- merge_rec_data(pct_time_cat2009_2010, +#' combined_pct_time_cat <- merge_rec_data(pct_time_cat2009_2010, #' pct_time_cat2011_2012) #' head(combined_pct_time_cat) #' tail(combined_pct_time_cat) #' +#' # Scalar usage +#' categorize_pct_time(55.5) +#' +#' # Vector usage +#' categorize_pct_time(c(5, 25, 55, 85, 100)) +#' #' @export -#' -pct_time_fun_cat <- - function(pct_time_der){ - if_else2(pct_time_der >= 0 & pct_time_der <= 10, 1, - if_else2(pct_time_der > 10 & pct_time_der <= 20, 2, - if_else2(pct_time_der > 20 & pct_time_der <= 30, 3, - if_else2(pct_time_der > 30 & pct_time_der <= 40, 4, - if_else2(pct_time_der > 40 & pct_time_der <= 50, 5, - if_else2(pct_time_der > 50 & pct_time_der <= 60, 6, - if_else2(pct_time_der > 60 & pct_time_der <= 70, 7, - if_else2(pct_time_der > 70 & pct_time_der <= 80, 8, - if_else2(pct_time_der > 80 & pct_time_der <= 90, 9, - if_else2(pct_time_der > 90 & pct_time_der <= 100, 10, - if_else2(haven::is_tagged_na(pct_time_der, "a"), "NA(a)", "NA(b)"))))))))))) +#' +categorize_pct_time <- + function(pct_time_der) { + dplyr::case_when( + haven::is_tagged_na(pct_time_der, "a") ~ "NA(a)", + pct_time_der >= 0 & pct_time_der <= 10 ~ "1", + pct_time_der > 10 & pct_time_der <= 20 ~ "2", + pct_time_der > 20 & pct_time_der <= 30 ~ "3", + pct_time_der > 30 & pct_time_der <= 40 ~ "4", + pct_time_der > 40 & pct_time_der <= 50 ~ "5", + pct_time_der > 50 & pct_time_der <= 60 ~ "6", + pct_time_der > 60 & pct_time_der <= 70 ~ "7", + pct_time_der > 70 & pct_time_der <= 80 ~ "8", + pct_time_der > 80 & pct_time_der <= 90 ~ "9", + pct_time_der > 90 & pct_time_der <= 100 ~ "10", + TRUE ~ "NA(b)" + ) } diff --git a/R/recode-with-table.R b/R/recode-with-table.R index 50658cae..61ba270e 100644 --- a/R/recode-with-table.R +++ b/R/recode-with-table.R @@ -147,7 +147,7 @@ is_equal <- function(v1, v2) { #' tail(combined_bmi) #' @importFrom haven tagged_na #' @importFrom stringr str_match -#' @importFrom dplyr rowwise select do +#' @importFrom dplyr rowwise select do case_when #' @importFrom magrittr %>% #' @export diff --git a/ceps/cep-008-immigration/PR-165-review-summary.md b/ceps/cep-008-immigration/PR-165-review-summary.md new file mode 100644 index 00000000..fb5ca273 --- /dev/null +++ b/ceps/cep-008-immigration/PR-165-review-summary.md @@ -0,0 +1,208 @@ +# CEP-008: Immigration / percent time in Canada — PR #165 review + +PR: https://github.com/Big-Life-Lab/cchsflow/pull/165 +Branch: `v3-pct-time-canada` → `v3` +Author: rafdoodle +Reviewed: 2026-02-12 + +## Scope + +**Variables reviewed:** DHH_AGE, SDCGCB, SDCGCBG, SDCDRES, SDCGRES, pct_time_der +**Database types:** PUMF (`_p`), Master (`_m`) +**Cycles:** 2001 through 2017-2018 + +### Changes in this PR (original + refactoring) + +- **2 new variables:** SDCGCB (master country of birth), SDCDRES (master continuous time in Canada) +- **1 new intermediate variable:** SDCGRES_cont (PUMF categorical → continuous midpoint conversion) +- **4 modified variables:** SDCGCBG (added cycles), SDCGRES (added cycles), DHH_AGE (expanded to master databases), pct_time_der (expanded to master databases, variableStart updated to use SDCGRES_cont for PUMF) +- **3 removed variables:** SDCGCBG_A, SDCGRES_A (consolidated into SDCGCB, SDCDRES), pct_time_der_A (merged into pct_time_der) +- **R function refactoring:** `pct_time_fun()` and `pct_time_fun_A()` removed — replaced with `calculate_pct_time(age, born_in_canada, years_in_canada)`. `pct_time_fun_cat()` renamed to `categorize_pct_time()`. Follows v3 verb-first naming convention. +- **`_s` databases removed:** All `_s` (deprecated share file) references purged from new/modified rows +- **Output bounds validation:** `calculate_pct_time()` clamps values outside [0, 100] to `tagged_na("b")`. Valid range documented in variable_details notes (documentation only, ready for future validation framework). +- **New tests:** 28 tests total (calculate_pct_time, categorize_pct_time, immigration_fun) + +## L3-L5 worksheet check findings + +### Issue 1: DHH_AGE databaseStart typo — `cchs2007_2008m` (P0, confidence 100) + +**PR-introduced.** Missing underscore before `m` suffix. Should be `cchs2007_2008_m`. + +Affects: variables.csv and all 4 variable_details.csv rows for DHH_AGE. + +### Issue 2: pct_time_der_A databaseStart double comma (P1, confidence 100) — RESOLVED + +**Resolved by merging pct_time_der_A into pct_time_der.** The double comma and `_s` references are eliminated. pct_time_der now has separate PUMF and master row sets under the same variable name. + +### Issue 3: DHH_AGE missing explicit 2015+ master mappings (informational, downgraded from P1) + +**Resolved by L0 DDI verification.** The `[DHH_AGE]` default applies to cchs2015_2016_m and cchs2017_2018_m without explicit `db::VAR` mappings. DDI verification confirms DHH_AGE was **not renamed** in 2015+ master files — it remains `DHH_AGE` through 2021 (renamed to `AWCAGE` only in 2022+). The default is safe. + +Adding explicit mappings is still best practice for consistency with other SDC variables in this PR (SDCDVCB, SDCDVRES, SDCDGCB, SDCDGRES). + +### Issue 4: SDCGCB dummyVariable uses `_NA::a` / `_NA::b` (P2, confidence 95) + +**PR-introduced.** The new SDCGCB variable uses colon notation in dummy names: +- `SDCGCB_cat2_NA::a` → should be `SDCGCB_cat2_NAa` +- `SDCGCB_cat2_NA::b` → should be `SDCGCB_cat2_NAb` +- `SDCGCB_cat7_NA::a` → should be `SDCGCB_cat7_NAa` +- `SDCGCB_cat7_NA::b` → should be `SDCGCB_cat7_NAb` + +**Pre-existing:** SDCGCBG and SDCGRES also use colon notation (on v3 branch). These are out of scope for this PR but should be addressed in a follow-up. + +### Issue 5: Missing unit tests for born-in-Canada case (P1, confidence 100) — RESOLVED + +**Resolved by refactoring.** Added tests for: +- Born-in-Canada (SDCGCBG=1, SDCGCB=1) → returns 100 for both variants +- `categorize_pct_time(100)` boundary → returns "10" +- `categorize_pct_time(tagged_na("a"))` → returns "NA(a)" +- Vector inputs for all three functions + +### Issue 6: Missing `man/pct_time_fun_A.Rd` documentation (P2, confidence 100) — RESOLVED + +**Resolved by removing `pct_time_fun_A`.** The function was eliminated during refactoring — both PUMF and master now use a single unified `calculate_pct_time()`. No separate .Rd file needed. + +### Informational: `_s` suffix databases — RESOLVED for pct_time_der + +**`_s` references removed from pct_time_der.** The deprecated share file databases (`cchs2009_s`, `cchs2010_s`, `cchs2012_s`) are no longer referenced in the combined pct_time_der rows. SDCGCB, SDCDRES, and DHH_AGE still reference `_s` on the v3 branch — these are pre-existing and out of scope for this PR. + +## L6 integration test — PUMF cross-cycle prevalence + +`rec_with_table()` ran successfully for all 9 PUMF cycles. No errors. + +| Cycle | N | DHHGAGE_cont | SDCGCBG | SDCGRES | pct_time_der | pct_time_der_cat10 | +|-------|---|-------------|---------|---------|-------------|-------------------| +| cchs2001_p | 200 | 100% | 100% | 100% | 100% | 100% | +| cchs2003_p | 200 | 100% | 100% | 100% | 96.5% | 100% | +| cchs2005_p | 200 | 100% | 100% | 100% | 93.5% | 100% | +| cchs2007_2008_p | 200 | 100% | 100% | 100% | 100% | 100% | +| cchs2009_2010_p | 200 | 100% | 100% | 100% | 98% | 100% | +| cchs2011_2012_p | 200 | 100% | 100% | 100% | 95% | 100% | +| cchs2013_2014_p | 200 | 100% | 100% | 100% | 96.5% | 100% | +| cchs2015_2016_p | 200 | 100% | 100% | 100% | 95.5% | 100% | +| cchs2017_2018_p | 200 | 100% | 100% | 100% | 98% | 100% | + +**No step changes at era boundaries.** The 2014→2015 transition shows normal variation (96.5% → 95.5%). + +**pct_time_der distribution:** Category 10 (90-100%) dominates across all cycles (~80%), consistent with most CCHS respondents being born in Canada. Category distributions are stable across the 2015 boundary. + +**Master (`_m`) variables** could not be tested at L6 — no runtime PUMF data available. Worksheet checks (issues 1-3) cover these. + +## L0 DDI verification — variable availability (cchsflow-docs) + +All name mappings in PR #165 verified against extracted YAML data dictionaries (2001-2023) and ICES DuckDB (2001-2021). + +### Name mapping verification: all correct + +| cchsflow name | Era | Mapped to | Verified | +|---------------|-----|-----------|----------| +| DHH_AGE | 2001 | DHHA_AGE | YAML+ICES | +| DHH_AGE | 2003 | DHHC_AGE | YAML+ICES | +| DHH_AGE | 2005 | DHHE_AGE | YAML+ICES | +| SDCGCB | 2001 | SDCAGCB | YAML+ICES | +| SDCGCB | 2003 | SDCCGCB | YAML+ICES | +| SDCGCB | 2005 | SDCEGCB | YAML+ICES | +| SDCGCB | 2011-2014 | SDCGCB10 | YAML+ICES | +| SDCGCB | 2015+ | SDCDVCB | YAML+ICES | +| SDCDRES | 2001 | SDCADRES | YAML+ICES | +| SDCDRES | 2003 | SDCCDRES | YAML+ICES | +| SDCDRES | 2005 | SDCEDRES | YAML+ICES | +| SDCDRES | 2015+ | SDCDVRES | YAML+ICES | +| SDCGCBG | 2001 | SDCAGCBG | YAML+ICES | +| SDCGCBG | 2003 | SDCCGCBG | YAML | +| SDCGCBG | 2005 | SDCEGCBG | YAML | +| SDCGCBG | 2011-2012 | SDCGCB12 | YAML+ICES | +| SDCGCBG | 2013-2014 | SDCGCB13 | YAML+ICES | +| SDCGCBG | 2015+ | SDCDGCB | YAML+ICES | +| SDCGRES | 2001 | SDCAGRES | YAML+ICES | +| SDCGRES | 2003 | SDCCGRES | YAML | +| SDCGRES | 2005 | SDCEGRES | YAML | +| SDCGRES | 2015+ | SDCDGRES | YAML | + +### Expansion opportunities (2019-2023) + +**Master variables** — all three inputs to `pct_time_der` (master rows) are confirmed through 2023: + +| Variable | Source var (2019+) | YAML coverage | ICES coverage | +|----------|--------------------|---------------|---------------| +| DHH_AGE | DHH_AGE (2019-2021), AWCAGE (2022-2023) | 2019-2023 | 2019-2021 | +| SDCGCB | SDCDVCB | 2019-2023 | 2019-2021 | +| SDCDRES | SDCDVRES | 2019-2023 | 2019-2021 | + +**PUMF variables** — limited expansion: + +| Variable | Source var (2019+) | Available? | +|----------|--------------------|------------| +| SDCGCBG | SDCDGCB | 2019-2020 PUMF only | +| SDCGRES | **Dropped** | Not available in 2019+ PUMF | + +`pct_time_der` PUMF rows **cannot** extend past 2017-2018 because SDCGRES was dropped. Master rows can extend through 2023 with appropriate mappings. + +## DV function review — `calculate_pct_time` + +### Original design issues (in PR #165 as submitted) + +1. **Early `return()` breaks vectorization** — `if (is_equal(SDCGCBG, 1)) { return(100) }` returns for the entire call when any element matches. Works for `rec_with_table()` (row-by-row) but fails for direct vector use. + +2. **`if_else2()` is legacy** — wrapper for `ifelse(falseifNA(x), a, b)`. No codebase functions have migrated to `dplyr::case_when()` yet, but deprecation is planned. + +3. **`pct_time_fun_A()` unnecessary** — introduced in this PR with near-duplicate logic. The only difference between PUMF and master was whether time-in-Canada was categorical (PUMF midpoints: 4.5 and 15 years) or continuous (master: actual years). Moving midpoints to the worksheet eliminates this distinction entirely. + +### Refactoring completed (in-scope for PR #165) + +**Done:** +- Replaced `if_else2()` with `dplyr::case_when()` for vectorized logic +- Replaced `is_equal()` + `if()`/`return()` with vectorized conditions +- **Removed `pct_time_fun()` and `pct_time_fun_A()`** — replaced with `calculate_pct_time(age, born_in_canada, years_in_canada)` +- **Renamed `pct_time_fun_cat()`** → `categorize_pct_time()` (v3 verb-first naming) +- Removed `pct_time_canada_core()` intermediate — logic inlined into `calculate_pct_time()` +- Moved PUMF midpoints from R code to worksheet: new `SDCGRES_cont` intermediate variable in `variable_details.csv` with `recEnd` midpoints (1→4.5, 2→15) +- `calculate_pct_time()` receives continuous years for both PUMF (via `SDCGRES_cont`) and master (via `SDCDRES`) +- `categorize_pct_time()` uses `case_when()`, returns uniform character type +- `pct_time_der` PUMF variableStart updated: `SDCGRES` → `SDCGRES_cont` +- **Removed `pct_time_der_A`** — merged into `pct_time_der` with separate PUMF and master row sets +- Purged `_s` database references from pct_time_der +- **Output bounds validation**: values outside [0, 100] → `tagged_na("b")`. Catches inconsistent inputs (e.g., years_in_canada > age). Documented in variable_details notes field (documentation only, ready for future validation framework). +- Roxygen examples for scalar, vector, and `rec_with_table()` usage +- 28 tests passing (0 failures), including: + - Born-in-Canada tests (born_in_canada=1 → returns 100) + - PUMF midpoint tests (years_in_canada=4.5, 15) + - Master continuous tests (years_in_canada=10) + - Vector input tests for calculate_pct_time and categorize_pct_time + - Boundary test: `categorize_pct_time(100)` → "10" + - `tagged_na("a")` test for `categorize_pct_time` + - NA handling for all three parameters + - Output bounds: years_in_canada > age → `tagged_na("b")` + - Output bounds: years_in_canada == age → exactly 100 (valid) + +**Deferred to post-v3-smoking merge:** +- Full 3-step architecture (`clean_variables()` + domain logic + output validation layer) +- Move inline bounds check from `calculate_pct_time()` to output validation layer +- Machine-enforce valid range metadata from variable_details (currently documentation only) + +**Worksheet changes (in CEP directory for review):** +- `SDCGRES_cont_variable_details.csv` — 5 new rows for SDCGRES_cont (cat→cont midpoint conversion) +- `SDCGRES_cont_variables.csv` — 1 new row for SDCGRES_cont in variables.csv +- `pct_time_der_combined_variable_details.csv` — 4 rows replacing both old pct_time_der (2) and pct_time_der_A (2): 2 PUMF rows + 2 master rows, all under `pct_time_der`, using `Func::calculate_pct_time` +- `pct_time_der_combined_variables.csv` — 1 row replacing both old pct_time_der and pct_time_der_A in variables.csv +- `pct_time_der_cat10_updated_variable_details.csv` — 13 rows updated from `Func::pct_time_fun_cat` to `Func::categorize_pct_time` + +**R files modified:** +- `R/percent-time-canada.R` — complete rewrite (`calculate_pct_time`, `categorize_pct_time`, semantic params) +- `tests/testthat/test-immigration.R` — complete rewrite (28 tests, continuous inputs + bounds validation) +- `NAMESPACE` — added `case_when` import, exports renamed to `calculate_pct_time` and `categorize_pct_time` +- `R/recode-with-table.R` — added `case_when` to `@importFrom` + +## Checks passed + +- Era boundary defaults: SDCGCB, SDCGCBG, SDCDRES, SDCGRES, pct_time_der — all SAFE +- databaseStart consistency: All 7 variables CONSISTENT between variables.csv and variable_details.csv +- PUMF/Master naming: No cross-contamination found +- Pre-2007 cycle letters: Correct (SDCA*, SDCC*, SDCE*, DHHA*, DHHC*, DHHE*) +- Known error patterns (cchs20013_, _i suffix, [[VAR]]): None found +- DV specification: Function parameters match worksheet variableStart +- L6 PUMF integration: All cycles pass, no step changes +- L0 DDI verification: All 22 name mappings verified against YAML+ICES (2001-2023) +- DV refactoring: `case_when()` replaces `if_else2()`, functions renamed to `calculate_pct_time` / `categorize_pct_time` (v3 convention), 28/28 tests pass +- Output bounds validation: values >100 or <0 → `tagged_na("b")`, documented in variable_details notes +- Unit test coverage: Born-in-Canada, PUMF midpoints, master continuous, vector inputs, boundary cases, output bounds, tagged_na all covered diff --git a/ceps/cep-008-immigration/SDCGRES_cont_variable_details.csv b/ceps/cep-008-immigration/SDCGRES_cont_variable_details.csv new file mode 100644 index 00000000..cb6fd6d9 --- /dev/null +++ b/ceps/cep-008-immigration/SDCGRES_cont_variable_details.csv @@ -0,0 +1,6 @@ +variable,dummyVariable,typeEnd,databaseStart,variableStart,ICES.confirmation,typeStart,recEnd,numValidCat,catLabel,catLabelLong,units,recStart,catStartLabel,variableStartShortLabel,variableStartLabel,notes,version,lastUpdated,status,reviewNotes,versionNotes,review +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,4.5,N/A,0 to 9 years,0 to 9 years,years,1,0 to 9 years,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,15,N/A,10 years or more,10 years or more,years,2,10 years or more,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::a,N/A,not applicable,not applicable,years,6,not applicable,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,N/A,missing,missing,years,"[7,9]",don't know (7); refusal (8); not stated (9),Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,N/A,missing,missing,years,else,else,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, diff --git a/ceps/cep-008-immigration/SDCGRES_cont_variables.csv b/ceps/cep-008-immigration/SDCGRES_cont_variables.csv new file mode 100644 index 00000000..9ec0b33c --- /dev/null +++ b/ceps/cep-008-immigration/SDCGRES_cont_variables.csv @@ -0,0 +1,2 @@ +variable,label,labelLong,variableType,databaseStart,variableStart,subject,section,units,notes,description,version,lastUpdated,reviewNotes,ICES.confirmation,Observation..MD.,status,versionNotes +SDCGRES_cont,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)",Continuous,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",Migration,Sociodemographics,years,"PUMF midpoint conversion from SDCGRES categorical (0-9 years -> 4.5, 10+ years -> 15).",,3.0.0,2026-02-12,,,,active, diff --git a/ceps/cep-008-immigration/cep-008-dv-verification.qmd b/ceps/cep-008-immigration/cep-008-dv-verification.qmd new file mode 100644 index 00000000..04877b7b --- /dev/null +++ b/ceps/cep-008-immigration/cep-008-dv-verification.qmd @@ -0,0 +1,299 @@ +--- +title: "CEP-008: Derived variable verification" +author: "cchsflow review (PR #165)" +date: "2026-02-12" +format: + html: + toc: true + code-fold: true +--- + +## Overview + +This document verifies the refactored `calculate_pct_time()` and `categorize_pct_time()` +derived variable functions from PR #165. The functions were refactored from +legacy `if_else2()` to `dplyr::case_when()`, and `calculate_pct_time_A()` was removed +in favour of a single unified function. + +**Key design change:** PUMF midpoints (4.5 and 15 years) were moved from +hardcoded R logic to the worksheet via the `SDCGRES_cont` intermediate variable. +Both PUMF and master paths now feed continuous years into the same function. + +```{r} +#| label: setup +#| message: false +#| warning: false + +devtools::load_all(here::here()) +library(haven) +library(dplyr) +``` + +## calculate_pct_time: scalar tests + +### Born in Canada + +Respondents born in Canada (born_in_canada = 1) should always return 100, +regardless of age or years_in_canada. + +```{r} +#| label: test-born-in-canada + +stopifnot(calculate_pct_time(27, 1, 4.5) == 100) +stopifnot(calculate_pct_time(80, 1, 0) == 100) +stopifnot(calculate_pct_time(1, 1, NA) == 100) +cat("PASS: born in Canada always returns 100\n") +``` + +### Continuous years calculation + +For immigrants (born_in_canada = 2), percent time = years_in_canada / age * 100. + +```{r} +#| label: test-continuous-calculation + +# PUMF midpoint: 0-9 years category (midpoint 4.5) +result <- calculate_pct_time(20, 2, 4.5) +stopifnot(result == 22.5) + +# PUMF midpoint: 10+ years category (midpoint 15) +result <- calculate_pct_time(20, 2, 15) +stopifnot(result == 75) + +# Master continuous: exact years +result <- calculate_pct_time(20, 2, 10) +stopifnot(result == 50) + +result <- calculate_pct_time(40, 2, 30) +stopifnot(result == 75) + +cat("PASS: continuous calculation correct for PUMF midpoints and master years\n") +``` + +### Missing data handling + +Invalid or missing inputs should return `tagged_na("b")`. + +```{r} +#| label: test-missing-data + +# Age out of range +stopifnot(is_tagged_na(calculate_pct_time(-1, 2, 4.5), "b")) +stopifnot(is_tagged_na(calculate_pct_time(0, 2, 4.5), "b")) + +# Invalid immigrant status +stopifnot(is_tagged_na(calculate_pct_time(20, 3, 4.5), "b")) +stopifnot(is_tagged_na(calculate_pct_time(20, 0, 4.5), "b")) + +# NA inputs +stopifnot(is_tagged_na(calculate_pct_time(NA, 2, 4.5), "b")) +stopifnot(is_tagged_na(calculate_pct_time(20, NA, 4.5), "b")) +stopifnot(is_tagged_na(calculate_pct_time(20, 2, NA), "b")) +stopifnot(is_tagged_na(calculate_pct_time(NA, NA, NA), "b")) + +cat("PASS: all invalid/missing inputs return tagged_na('b')\n") +``` + +### Output bounds validation + +Values outside [0, 100] indicate inconsistent inputs (e.g., years_in_canada > age). +These are treated as data quality errors and return `tagged_na("b")`. + +```{r} +#| label: test-output-bounds + +# years_in_canada > age → impossible percentage (>100) +stopifnot(is_tagged_na(calculate_pct_time(20, 2, 25), "b")) + +# Exact boundary: years_in_canada == age → 100% (valid) +stopifnot(calculate_pct_time(20, 2, 20) == 100) + +# Just under boundary +result <- calculate_pct_time(20, 2, 19) +stopifnot(result == 95) + +# Vector with out-of-bounds element +result <- calculate_pct_time( + age = c(20, 30, 10), + born_in_canada = c(2, 2, 2), + years_in_canada = c(10, 35, 5) +) +stopifnot(result[1] == 50) +stopifnot(is_tagged_na(result[2], "b")) # 35/30 = 116.7% → invalid +stopifnot(result[3] == 50) + +cat("PASS: output bounds validation catches impossible percentages\n") +``` + +## calculate_pct_time: vectorised tests + +The refactored function must work with vector inputs (not just row-by-row via +`rec_with_table()`). The original `if()`/`return()` pattern broke vectorisation. + +```{r} +#| label: test-vectorised + +result <- calculate_pct_time( + age = c(20, 40, 30, 25, NA), + born_in_canada = c(2, 1, 2, 2, 2), + years_in_canada = c(4.5, 4.5, 15, 10, 5) +) + +stopifnot(length(result) == 5) +stopifnot(result[1] == 22.5) # immigrant, 4.5/20 * 100 +stopifnot(result[2] == 100) # born in Canada +stopifnot(result[3] == 50) # immigrant, 15/30 * 100 +stopifnot(result[4] == 40) # immigrant, 10/25 * 100 +stopifnot(is_tagged_na(result[5], "b")) # NA age + +cat("PASS: vectorised input produces correct element-wise results\n") +``` + +### Mixed vector with all pathways + +```{r} +#| label: test-mixed-vector + +result <- calculate_pct_time( + age = c(30, 50, -1, 20, 40), + born_in_canada = c(1, 2, 2, 3, 2), + years_in_canada = c(10, 25, 5, 10, NA) +) + +stopifnot(result[1] == 100) # born in Canada +stopifnot(result[2] == 50) # 25/50 * 100 +stopifnot(is_tagged_na(result[3], "b")) # negative age +stopifnot(is_tagged_na(result[4], "b")) # invalid born_in_canada = 3 +stopifnot(is_tagged_na(result[5], "b")) # NA years_in_canada + +cat("PASS: mixed vector with all pathways\n") +``` + +## categorize_pct_time: categorical binning + +The categorical function bins continuous percent time into deciles ("1" through +"10"), with "NA(a)" for not applicable and "NA(b)" for missing/invalid. + +```{r} +#| label: test-cat-boundaries + +# Boundary values for each bin +boundaries <- data.frame( + input = c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, + 55, 60, 65, 70, 75, 80, 85, 90, 95, 100), + expected = c("1", "1", "1", "2", "2", "3", "3", "4", "4", "5", "5", + "6", "6", "7", "7", "8", "8", "9", "9", "10", "10") +) + +results <- categorize_pct_time(boundaries$input) +mismatches <- boundaries[results != boundaries$expected, ] + +if (nrow(mismatches) > 0) { + cat("FAIL: mismatches found\n") + print(mismatches) + stop("Boundary test failed") +} else { + cat("PASS: all", nrow(boundaries), "boundary values correctly binned\n") +} +``` + +### Special values + +```{r} +#| label: test-cat-special + +# tagged_na("a") -> "NA(a)" +stopifnot(categorize_pct_time(tagged_na("a")) == "NA(a)") + +# tagged_na("b") -> "NA(b)" +stopifnot(categorize_pct_time(tagged_na("b")) == "NA(b)") + +# Out of range -> "NA(b)" +stopifnot(categorize_pct_time(-1) == "NA(b)") +stopifnot(categorize_pct_time(101) == "NA(b)") + +# Vector +result <- categorize_pct_time(c(5, 25, 55, 85, 100)) +stopifnot(identical(result, c("1", "3", "6", "9", "10"))) + +cat("PASS: special values and vector input handled correctly\n") +``` + +## Return type verification + +The refactored functions must return consistent types — `calculate_pct_time` returns +numeric (with `tagged_na` for missing), `categorize_pct_time` returns character. + +```{r} +#| label: test-return-types + +# calculate_pct_time returns numeric +r1 <- calculate_pct_time(20, 2, 10) +stopifnot(is.numeric(r1)) + +r2 <- calculate_pct_time(20, 1, 10) +stopifnot(is.numeric(r2)) + +r3 <- calculate_pct_time(NA, 2, 10) +stopifnot(is.numeric(r3)) +stopifnot(is.na(r3)) + +# categorize_pct_time returns character +r4 <- categorize_pct_time(50) +stopifnot(is.character(r4)) + +r5 <- categorize_pct_time(-1) +stopifnot(is.character(r5)) + +r6 <- categorize_pct_time(tagged_na("a")) +stopifnot(is.character(r6)) + +cat("PASS: return types are consistent (numeric and character)\n") +``` + +## haven tagged_na verification + +Confirm that `tagged_na("b")` is correctly produced and detectable. This +validates the haven integration — `tagged_na` values are NA to `is.na()` but +carry a tag accessible via `is_tagged_na()`. + +```{r} +#| label: test-tagged-na + +missing_result <- calculate_pct_time(NA, 2, 4.5) + +# It is NA +stopifnot(is.na(missing_result)) + +# It is specifically tagged_na("b") +stopifnot(haven::is_tagged_na(missing_result, "b")) + +# It is not tagged_na("a") +stopifnot(!haven::is_tagged_na(missing_result, "a")) + +# Numeric comparison with tagged_na works +stopifnot(identical(missing_result, tagged_na("b"))) + +cat("PASS: haven tagged_na correctly produced and detectable\n") +``` + +## Summary + +```{r} +#| label: summary + +cat("\n=== ALL VERIFICATION TESTS PASSED ===\n\n") +cat("Functions verified:\n") +cat(" calculate_pct_time(age, born_in_canada, years_in_canada)\n") +cat(" categorize_pct_time(pct_time_der)\n\n") +cat("Test categories:\n") +cat(" - Born-in-Canada pathway (returns 100)\n") +cat(" - Continuous calculation (PUMF midpoints and master years)\n") +cat(" - Missing data handling (tagged_na('b'))\n") +cat(" - Output bounds validation (>100% → tagged_na('b'))\n") +cat(" - Vectorised operation (all pathways in single call)\n") +cat(" - Categorical binning (21 boundary values)\n") +cat(" - Special values (tagged_na('a'), out of range)\n") +cat(" - Return type consistency (numeric, character)\n") +cat(" - haven tagged_na integration\n") +``` diff --git a/ceps/cep-008-immigration/pct_time_der_cat10_updated_variable_details.csv b/ceps/cep-008-immigration/pct_time_der_cat10_updated_variable_details.csv new file mode 100644 index 00000000..b2517ed9 --- /dev/null +++ b/ceps/cep-008-immigration/pct_time_der_cat10_updated_variable_details.csv @@ -0,0 +1,14 @@ +"variable","dummyVariable","typeEnd","databaseStart","variableStart","ICES.confirmation","typeStart","recEnd","numValidCat","catLabel","catLabelLong","units","recStart","catStartLabel","variableStartShortLabel","variableStartLabel","notes","version","lastUpdated","status","reviewNotes","versionNotes","review" +"pct_time_der_cat10","pct_time_der_cat10N/A_Func::pct_time_fun_cat","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","Func::categorize_pct_time","N/A","N/A","N/A","%","N/A","N/A","Categorical percent time in Canada","Categorical percentage of time in Canada","Categorical percent time in Canada derived from pct_time_der","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_1","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","1","10","10%","10% time in Canada","%","1","10% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_2","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","2","10","20%","20% time in Canada","%","2","20% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_3","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","3","10","30%","30% time in Canada","%","3","30% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_4","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","4","10","40%","40% time in Canada","%","4","40% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_5","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","5","10","50%","50% time in Canada","%","5","50% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_6","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","6","10","60%","60% time in Canada","%","6","60% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_7","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","7","10","70%","70% time in Canada","%","7","70% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_8","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","8","10","80%","80% time in Canada","%","8","80% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_9","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","9","10","90%","90% time in Canada","%","9","90% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_10","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","10","10","100%","100% time in Canada","%","10","100% time in Canada","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_NA::a","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","NA::a","10","not applicable","not applicable","%","NA::a","not applicable","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" +"pct_time_der_cat10","pct_time_der_cat10_NA::b","cat","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[pct_time_der]","","N/A","NA::b","10","missing","missing","%","NA::b","missing","Categorical percent time in Canada","Categorical percentage of time in Canada","","2.2.0","2025-11-18","active","","","" diff --git a/ceps/cep-008-immigration/pct_time_der_combined_variable_details.csv b/ceps/cep-008-immigration/pct_time_der_combined_variable_details.csv new file mode 100644 index 00000000..e97de6b0 --- /dev/null +++ b/ceps/cep-008-immigration/pct_time_der_combined_variable_details.csv @@ -0,0 +1,5 @@ +"variable","dummyVariable","typeEnd","databaseStart","variableStart","ICES.confirmation","typeStart","recEnd","numValidCat","catLabel","catLabelLong","units","recStart","catStartLabel","variableStartShortLabel","variableStartLabel","notes","version","lastUpdated","status","reviewNotes","versionNotes","review" +"pct_time_der","N/A","cont","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES_cont]",NA,"N/A","Func::calculate_pct_time","N/A","N/A","N/A","%","N/A","N/A","Percent time in Canada","Percentage of time in Canada","Percent time in Canada derived from Age, immigration status, and time in Canada variables. Valid range: 0-100. Output boundary enforced in DV function; see calculate_pct_time(). Documentation only in variable_details, ready for use in future validation framework.","2.2.0","2025-11-18","active",NA,NA,NA +"pct_time_der","N/A","cont","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES_cont]",NA,"N/A","NA::b","N/A","missing","missing","%","N/A","N/A","Percent time in Canada","Percentage of time in Canada","","2.2.0","2025-11-18","active",NA,NA,NA +"pct_time_der","N/A","cont","cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[DHH_AGE, SDCGCB, SDCDRES]",NA,"N/A","Func::calculate_pct_time","N/A","N/A","N/A","%","N/A","N/A","Percent time in Canada","Percentage of time in Canada","Percent time in Canada derived from continuous Age, immigration status, and continuous time in Canada variables (master files). Valid range: 0-100. Output boundary enforced in DV function; see calculate_pct_time(). Documentation only in variable_details, ready for use in future validation framework.","3.0.0","2026-02-06","active",NA,NA,NA +"pct_time_der","N/A","cont","cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[DHH_AGE, SDCGCB, SDCDRES]",NA,"N/A","NA::b","N/A","missing","missing","%","N/A","N/A","Percent time in Canada","Percentage of time in Canada","","3.0.0","2026-02-06","active",NA,NA,NA diff --git a/ceps/cep-008-immigration/pct_time_der_combined_variables.csv b/ceps/cep-008-immigration/pct_time_der_combined_variables.csv new file mode 100644 index 00000000..b7deeecc --- /dev/null +++ b/ceps/cep-008-immigration/pct_time_der_combined_variables.csv @@ -0,0 +1,2 @@ +"variable","label","labelLong","variableType","databaseStart","variableStart","subject","section","units","notes","description","version","lastUpdated","reviewNotes","ICES.confirmation","Observation..MD.","status","versionNotes" +"pct_time_der","Percent time in Canada","Percentage of time in Canada","Continuous","cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES_cont, DHH_AGE, SDCGCB, SDCDRES]","Migration","Sociodemographics","%","","","2.2.0","2025-06-30","Variable metadata completed","",NA,"active","" diff --git a/inst/extdata/variable_details.csv b/inst/extdata/variable_details.csv index b3ad3dd3..ffb60a44 100644 --- a/inst/extdata/variable_details.csv +++ b/inst/extdata/variable_details.csv @@ -547,10 +547,10 @@ DEPDVSEV,DEPDVSEV_cat6_6,cat,"cchs2015_2016_p, cchs2017_2018_p",[DEPDVPHQ],,cat, DEPDVSEV,DEPDVSEV_cat6_NA::a,cat,"cchs2015_2016_p, cchs2017_2018_p",[DEPDVPHQ],,cat,NA::a,6,not applicable,not applicable,N/A,6,not applicable,Depression scale - severity of depression,Depression scale - severity of depression,,2.2.0,2025-11-18,active,,, DEPDVSEV,DEPDVSEV_cat6_NA::b,cat,"cchs2015_2016_p, cchs2017_2018_p",[DEPDVPHQ],,cat,NA::b,6,missing,missing,N/A,"[7,9]",not stated,Depression scale - severity of depression,Depression scale - severity of depression,,2.2.0,2025-11-18,active,,, DEPDVSEV,DEPDVSEV_cat6_NA::b,cat,"cchs2015_2016_p, cchs2017_2018_p",[DEPDVPHQ],,cat,NA::b,6,missing,missing,N/A,else,else,Depression scale - severity of depression,Depression scale - severity of depression,,2.2.0,2025-11-18,active,,, -DHH_AGE,N/A,cont,"cchs2009_s, cchs2010_s, cchs2012_s",[DHH_AGE],,cont,copy,N/A,Age,continuous age,years,"[12,102]",Age,Age,Continuous age,Share files have continuous age.,2.2.0,2025-11-18,active,,, -DHH_AGE,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",[DHH_AGE],,cont,NA::a,N/A,not applicable,not applicable,years,96,not applicable,Age,Continuous age,,2.2.0,2025-11-18,active,,, -DHH_AGE,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",[DHH_AGE],,cont,NA::b,N/A,missing,missing,years,"[97,99]",don't know (97); refusal (98); not stated (99),Age,Continuous age,,2.2.0,2025-11-18,active,,, -DHH_AGE,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",[DHH_AGE],,cont,NA::b,N/A,missing,missing,years,else,else,Age,Continuous age,,2.2.0,2025-11-18,active,,, +DHH_AGE,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2011_2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_m::DHHA_AGE, cchs2003_m::DHHC_AGE, cchs2005_m::DHHE_AGE, [DHH_AGE]",,cont,copy,N/A,Age,continuous age,years,"[12,102]",Age,Age,Continuous age,Share files have continuous age.,2.2.0,2025-11-18,active,,, +DHH_AGE,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2011_2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_m::DHHA_AGE, cchs2003_m::DHHC_AGE, cchs2005_m::DHHE_AGE, [DHH_AGE]",,cont,NA::a,N/A,not applicable,not applicable,years,96,not applicable,Age,Continuous age,,2.2.0,2025-11-18,active,,, +DHH_AGE,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2011_2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_m::DHHA_AGE, cchs2003_m::DHHC_AGE, cchs2005_m::DHHE_AGE, [DHH_AGE]",,cont,NA::b,N/A,missing,missing,years,"[97,99]",don't know (97); refusal (98); not stated (99),Age,Continuous age,,2.2.0,2025-11-18,active,,, +DHH_AGE,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2011_2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_m::DHHA_AGE, cchs2003_m::DHHC_AGE, cchs2005_m::DHHE_AGE, [DHH_AGE]",,cont,NA::b,N/A,missing,missing,years,else,else,Age,Continuous age,,2.2.0,2025-11-18,active,,, DHH_OWN,DHH_OWN_cat2_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::DHHA_OWN, cchs2003_p::DHHC_OWN, cchs2005_p::DHHE_OWN, [DHH_OWN]",,cat,1,2,Yes,Yes,N/A,1,Yes,Home ownership,Dwelling - owned by a member of hsld,"Prior to 2009, CCHS restricted this variable to participants who were not living in an institution. In 2011, CCHS changed wording of responses to (1) owner and (2) renter",2.2.0,2025-11-18,active,,, DHH_OWN,DHH_OWN_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::DHHA_OWN, cchs2003_p::DHHC_OWN, cchs2005_p::DHHE_OWN, [DHH_OWN]",,cat,2,2,No,No,N/A,2,No,Home ownership,Dwelling - owned by a member of hsld,,2.2.0,2025-11-18,active,,, DHH_OWN,DHH_OWN_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::DHHA_OWN, cchs2003_p::DHHC_OWN, cchs2005_p::DHHE_OWN, [DHH_OWN]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Home ownership,Dwelling - owned by a member of hsld,,2.2.0,2025-11-18,active,,, @@ -2318,21 +2318,23 @@ PAYDVVIG,N/A,cont,"cchs2015_2016_p, cchs2017_2018_p, cchs2015_2016_m, cchs2017_2 PAYDVVIG,N/A,cont,"cchs2015_2016_p, cchs2017_2018_p, cchs2015_2016_m, cchs2017_2018_m",[PAYDVVIG],,cont,NA::a,N/A,not applicable,not applicable,minutes/week,99996,not applicable,Vigorous activities (12-17 years old),Time spent - vigorous activity in a week (12-17 years old),,,,active,,, PAYDVVIG,N/A,cont,"cchs2015_2016_p, cchs2017_2018_p, cchs2015_2016_m, cchs2017_2018_m",[PAYDVVIG],,cont,NA::b,N/A,missing,missing,minutes/week,"[99997,99999]",don't know (99997); refusal (99998); not stated (99999),Vigorous activities (12-17 years old),Time spent - vigorous activity in a week (12-17 years old),,,,active,,, PAYDVVIG,N/A,cont,"cchs2015_2016_p, cchs2017_2018_p, cchs2015_2016_m, cchs2017_2018_m",[PAYDVVIG],,cont,NA::b,N/A,missing,missing,minutes/week,else,else,Vigorous activities (12-17 years old),Time spent - vigorous activity in a week (12-17 years old),,,,active,,, -pct_time_der,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES]",,N/A,Func::pct_time_fun,N/A,N/A,N/A,%,N/A,N/A,Percent time in Canada,Percentage of time in Canada,"Percent time in Canada derived from Age, immigration status, and time in Canada variables",2.2.0,2025-11-18,active,,, -pct_time_der,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES]",,N/A,NA::b,N/A,missing,missing,%,N/A,N/A,Percent time in Canada,Percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10N/A_Func::pct_time_fun_cat,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,Func::pct_time_fun_cat,N/A,N/A,N/A,%,N/A,N/A,Categorical percent time in Canada,Categorical percentage of time in Canada,Categorical percent time in Canada derived from pct_time_der,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,1,10,10%,10% time in Canada,%,1,10% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,2,10,20%,20% time in Canada,%,2,20% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_3,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,3,10,30%,30% time in Canada,%,3,30% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_4,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,4,10,40%,40% time in Canada,%,4,40% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_5,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,5,10,50%,50% time in Canada,%,5,50% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_6,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,6,10,60%,60% time in Canada,%,6,60% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_7,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,7,10,70%,70% time in Canada,%,7,70% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_8,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,8,10,80%,80% time in Canada,%,8,80% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_9,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,9,10,90%,90% time in Canada,%,9,90% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_10,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,10,10,100%,100% time in Canada,%,10,100% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,NA::a,10,not applicable,not applicable,%,NA::a,not applicable,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, -pct_time_der_cat10,pct_time_der_cat10_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],,N/A,NA::b,10,missing,missing,%,NA::b,missing,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES_cont]",,N/A,Func::calculate_pct_time,N/A,N/A,N/A,%,N/A,N/A,Percent time in Canada,Percentage of time in Canada,"Percent time in Canada derived from Age, immigration status, and time in Canada variables. Valid range: 0-100. Output boundary enforced in DV function; see calculate_pct_time(). Documentation only in variable_details, ready for use in future validation framework.",2.2.0,2025-11-18,active,,, +pct_time_der,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES_cont]",,N/A,NA::b,N/A,missing,missing,%,N/A,N/A,Percent time in Canada,Percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[DHH_AGE, SDCGCB, SDCDRES]",,N/A,Func::calculate_pct_time,N/A,N/A,N/A,%,N/A,N/A,Percent time in Canada,Percentage of time in Canada,"Percent time in Canada derived from continuous Age, immigration status, and continuous time in Canada variables (master files). Valid range: 0-100. Output boundary enforced in DV function; see calculate_pct_time(). Documentation only in variable_details, ready for use in future validation framework.",3.0.0,2026-02-06,active,,, +pct_time_der,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[DHH_AGE, SDCGCB, SDCDRES]",,N/A,NA::b,N/A,missing,missing,%,N/A,N/A,Percent time in Canada,Percentage of time in Canada,,3.0.0,2026-02-06,active,,, +pct_time_der_cat10,pct_time_der_cat10N/A_Func::pct_time_fun_cat,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,Func::categorize_pct_time,N/A,N/A,N/A,%,N/A,N/A,Categorical percent time in Canada,Categorical percentage of time in Canada,Categorical percent time in Canada derived from pct_time_der,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,1,10,10%,10% time in Canada,%,1,10% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,2,10,20%,20% time in Canada,%,2,20% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_3,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,3,10,30%,30% time in Canada,%,3,30% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_4,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,4,10,40%,40% time in Canada,%,4,40% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_5,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,5,10,50%,50% time in Canada,%,5,50% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_6,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,6,10,60%,60% time in Canada,%,6,60% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_7,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,7,10,70%,70% time in Canada,%,7,70% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_8,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,8,10,80%,80% time in Canada,%,8,80% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_9,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,9,10,90%,90% time in Canada,%,9,90% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_10,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,10,10,100%,100% time in Canada,%,10,100% time in Canada,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,NA::a,10,not applicable,not applicable,%,NA::a,not applicable,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, +pct_time_der_cat10,pct_time_der_cat10_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],,N/A,NA::b,10,missing,missing,%,NA::b,missing,Categorical percent time in Canada,Categorical percentage of time in Canada,,2.2.0,2025-11-18,active,,, RAC_1,RAC_1_cat3_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::RACA_1, cchs2003_p::RACC_1, cchs2005_p::RACE_1, [RAC_1]",,cat,1,3,Sometimes,Sometimes,N/A,1,Sometimes,Difficulty activities,Has difficulty with activities,,2.2.0,2025-11-18,active,,, RAC_1,RAC_1_cat3_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::RACA_1, cchs2003_p::RACC_1, cchs2005_p::RACE_1, [RAC_1]",,cat,2,3,Often,Often,N/A,2,Often,Difficulty activities,Has difficulty with activities,,2.2.0,2025-11-18,active,,, RAC_1,RAC_1_cat3_3,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::RACA_1, cchs2003_p::RACC_1, cchs2005_p::RACE_1, [RAC_1]",,cat,3,3,Never,Never,N/A,3,Never,Difficulty activities,Has difficulty with activities,,2.2.0,2025-11-18,active,,, @@ -2559,26 +2561,26 @@ SDCFIMM,SDCFIMM_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, SDCFIMM,SDCFIMM_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAFIMM, cchs2003_p::SDCCFIMM, cchs2005_p::SDCEFIMM, cchs2015_2016_p::SDCDVIMM, cchs2017_2018_p::SDCDVIMM, [SDCFIMM]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Immigrant status,Immigrant Status (D),,2.2.0,2025-11-18,active,,, SDCFIMM,SDCFIMM_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAFIMM, cchs2003_p::SDCCFIMM, cchs2005_p::SDCEFIMM, cchs2015_2016_p::SDCDVIMM, cchs2017_2018_p::SDCDVIMM, [SDCFIMM]",,cat,NA::b,2,missing,missing,N/A,"[7,9]",don't know (7); refusal (8); not stated (9),Immigrant status,Immigrant Status (D),,2.2.0,2025-11-18,active,,, SDCFIMM,SDCFIMM_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAFIMM, cchs2003_p::SDCCFIMM, cchs2005_p::SDCEFIMM, cchs2015_2016_p::SDCDVIMM, cchs2017_2018_p::SDCDVIMM, [SDCFIMM]",,cat,NA::b,2,missing,missing,N/A,else,else,Immigrant status,Immigrant Status (D),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,1,2,Canada,Canada,N/A,1,Canada,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,2,2,Other,Other,N/A,2,Other,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,NA::b,2,missing,missing,N/A,"[7,9]",don't know (7); refusal (8); not stated (9),Country of birth,Country of birth - (G),CCHS 2001 does not have don't know (7) or refusal (8),2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,NA::b,2,missing,missing,N/A,else,else,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_1,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,1,2,Canada,Canada,N/A,1,Canada,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_2,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,2,2,Other,Other,N/A,"[2,7]",Other,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_NA::a,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::a,2,not applicable,not applicable,N/A,96,not applicable,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::b,2,missing,missing,N/A,"[97,99]",don't know (97); refusal (98); not stated (99),Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG,SDCGCBG_cat2_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::b,2,missing,missing,N/A,else,else,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_1,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,1,7,Canada,Canada,N/A,1,Canada,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_2,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,2,7,Other North America,Other North America,N/A,2,Other North America,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_3,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,3,7,"South, Central America and Caribbean","South, Central America and Caribbean",N/A,3,"South, Central America and Caribbean",Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_4,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,4,7,Europe,Europe,N/A,4,Europe,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_5,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,5,7,Africa,Africa,N/A,5,Africa,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_6,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,6,7,Asia,Asia,N/A,6,Asia,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_7,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,7,7,Oceania,Oceania,N/A,7,Oceania,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_NA::a,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::a,7,not applicable,not applicable,N/A,96,not applicable,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::b,7,missing,missing,N/A,"[97,99]",don't know (97); refusal (98); not stated (99),Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, -SDCGCBG_A,SDCGCBG_A_cat7_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::b,7,missing,missing,N/A,else,else,Country of birth,Country of birth - (G),,2.2.0,2025-11-18,active,,, +SDCGCB,SDCGCB_cat2_1,cat,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCAGCB, cchs2003_m::SDCCGCB, cchs2005_m::SDCEGCB, cchs2011_2012_m::SDCGCB10, cchs2013_2014_m::SDCGCB10, cchs2015_2016_m::SDCDVCB, cchs2017_2018_m::SDCDVCB, [SDCGCB]",,cat,1,2,Canada,Canada,N/A,1,Canada,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat2_2,cat,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCAGCB, cchs2003_m::SDCCGCB, cchs2005_m::SDCEGCB, cchs2011_2012_m::SDCGCB10, cchs2013_2014_m::SDCGCB10, cchs2015_2016_m::SDCDVCB, cchs2017_2018_m::SDCDVCB, [SDCGCB]",,cat,2,2,Other,Other,N/A,"[2,7]",Other,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat2_NA::a,cat,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCAGCB, cchs2003_m::SDCCGCB, cchs2005_m::SDCEGCB, cchs2011_2012_m::SDCGCB10, cchs2013_2014_m::SDCGCB10, cchs2015_2016_m::SDCDVCB, cchs2017_2018_m::SDCDVCB, [SDCGCB]",,cat,NA::a,2,not applicable,not applicable,N/A,96,not applicable,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat2_NA::b,cat,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCAGCB, cchs2003_m::SDCCGCB, cchs2005_m::SDCEGCB, cchs2011_2012_m::SDCGCB10, cchs2013_2014_m::SDCGCB10, cchs2015_2016_m::SDCDVCB, cchs2017_2018_m::SDCDVCB, [SDCGCB]",,cat,NA::b,2,missing,missing,N/A,"[97,99]",don't know (7); refusal (8); not stated (9),Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat2_NA::b,cat,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCAGCB, cchs2003_m::SDCCGCB, cchs2005_m::SDCEGCB, cchs2011_2012_m::SDCGCB10, cchs2013_2014_m::SDCGCB10, cchs2015_2016_m::SDCDVCB, cchs2017_2018_m::SDCDVCB, [SDCGCB]",,cat,NA::b,2,missing,missing,N/A,else,else,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_1,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,1,7,Canada,Canada,N/A,1,Canada,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_2,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,2,7,Other North America,Other North America,N/A,2,Other North America,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_3,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,3,7,"South, Central America and Caribbean","South, Central America and Caribbean",N/A,3,"South, Central America and Caribbean",Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_4,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,4,7,Europe,Europe,N/A,4,Europe,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_5,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,5,7,Africa,Africa,N/A,5,Africa,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_6,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,6,7,Asia,Asia,N/A,6,Asia,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_7,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,7,7,Oceania,Oceania,N/A,7,Oceania,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_NA::a,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::a,7,not applicable,not applicable,N/A,96,not applicable,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::b,7,missing,missing,N/A,"[97,99]",don't know (97); refusal (98); not stated (99),Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCB,SDCGCB_cat7_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",,cat,NA::b,7,missing,missing,N/A,else,else,Country of birth,Country of birth - (G),,3.0.0,2026-02-06,active,,, +SDCGCBG,SDCGCBG_cat2_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,1,2,Canada,Canada,N/A,1,Canada,Country of birth,Country of birth - (G),,2.2.0,2026-02-06,active,,, +SDCGCBG,SDCGCBG_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,2,2,Other,Other,N/A,2,Other,Country of birth,Country of birth - (G),,2.2.0,2026-02-06,active,,, +SDCGCBG,SDCGCBG_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Country of birth,Country of birth - (G),,2.2.0,2026-02-06,active,,, +SDCGCBG,SDCGCBG_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,NA::b,2,missing,missing,N/A,"[7,9]",don't know (7); refusal (8); not stated (9),Country of birth,Country of birth - (G),CCHS 2001 does not have don't know (7) or refusal (8),2.2.0,2026-02-06,active,,, +SDCGCBG,SDCGCBG_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",,cat,NA::b,2,missing,missing,N/A,else,else,Country of birth,Country of birth - (G),,2.2.0,2026-02-06,active,,, SDCGCGT,SDCGCGT_cat2_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRAC, cchs2003_p::SDCCGRAC, cchs2005_p::SDCEGCGT, cchs2015_2016_p::SDCDGCGT, cchs2017_2018_p::SDCDGCGT, [SDCGCGT]",,cat,1,2,White,White,N/A,1,White,Ethnicity,"Cultural or racial origin - (D, G)",,2.2.0,2025-11-18,active,,, SDCGCGT,SDCGCGT_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRAC, cchs2003_p::SDCCGRAC, cchs2005_p::SDCEGCGT, cchs2015_2016_p::SDCDGCGT, cchs2017_2018_p::SDCDGCGT, [SDCGCGT]",,cat,2,2,Non-white,Non-white,N/A,2,Visible minority,Ethnicity,"Cultural or racial origin - (D, G)",,2.2.0,2025-11-18,active,,, SDCGCGT,SDCGCGT_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRAC, cchs2003_p::SDCCGRAC, cchs2005_p::SDCEGCGT, cchs2015_2016_p::SDCDGCGT, cchs2017_2018_p::SDCDGCGT, [SDCGCGT]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Ethnicity,"Cultural or racial origin - (D, G)",,2.2.0,2025-11-18,active,,, @@ -2657,20 +2659,20 @@ SDCGLNG_A,SDCGLNG_A_cat7_7,cat,"cchs2009_s, cchs2010_s",[SDCDLNG],,cat,7,7,Neith SDCGLNG_A,SDCGLNG_A_cat7_NA::a,cat,"cchs2009_s, cchs2010_s",[SDCDLNG],,cat,NA::a,7,not applicable,not applicable,N/A,96,not applicable,Languages - can converse in,Languages - can converse in - (D),,2.2.0,2025-11-18,active,,, SDCGLNG_A,SDCGLNG_A_cat7_NA::b,cat,"cchs2009_s, cchs2010_s",[SDCDLNG],,cat,NA::b,7,missing,missing,N/A,"[97,99]",don't know (97); refusal (98); not stated (99),Languages - can converse in,Languages - can converse in - (D),,2.2.0,2025-11-18,active,,, SDCGLNG_A,SDCGLNG_A_cat7_NA::b,cat,"cchs2009_s, cchs2010_s",[SDCDLNG],,cat,NA::b,7,missing,missing,N/A,else,else,Languages - can converse in,Languages - can converse in - (D),,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,1,2,0 to 9 years,0 to 9 years,N/A,1,0 to 9 years,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,2,2,10 years or more,10 years or more,N/A,2,10 years or more,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,2,missing,missing,N/A,"[7,9]",don't know (7); refusal (8); not stated (9),Time in Canada,"Length/time in Canada since imm. (D, G)","CCHS 2001 missing don't know (7), refusal (8)",2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,2,missing,missing,N/A,else,else,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_1,cat,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,1,2,0 to 9 years,0 to 9 years,N/A,"[0,10)",0 to 9 years,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_2,cat,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,2,2,10 years or more,10 years or more,N/A,"[10,97]",10 years or more,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_NA::a,cat,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,NA::a,2,not applicable,not applicable,N/A,996,not applicable,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,NA::b,2,missing,missing,N/A,"[997,999]",don't know (997); refusal (998); not stated (999),Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES,SDCGRES_cat2_NA::b,cat,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,NA::b,2,missing,missing,N/A,else,else,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2025-11-18,active,,, -SDCGRES_A,N/A,cont,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,copy,N/A,years since immigration,years since immigration,years,"[0,97]",years since immigration,Time in Canada,Length/time in Canada since imm. (D),,2.2.0,2025-11-18,active,,, -SDCGRES_A,N/A,cont,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,NA::a,N/A,not applicable,not applicable,years,996,not applicable,Time in Canada,Length/time in Canada since imm. (D),,2.2.0,2025-11-18,active,,, -SDCGRES_A,N/A,cont,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,NA::b,N/A,missing,missing,years,"[997,999]",don't know (997); refusal (998); not stated (999),Time in Canada,Length/time in Canada since imm. (D),,2.2.0,2025-11-18,active,,, -SDCGRES_A,N/A,cont,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],,cont,NA::b,N/A,missing,missing,years,else,else,Time in Canada,Length/time in Canada since imm. (D),,2.2.0,2025-11-18,active,,, +SDCDRES,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCADRES, cchs2003_m::SDCCDRES, cchs2005_m::SDCEDRES, cchs2015_2016_m::SDCDVRES, cchs2017_2018_m::SDCDVRES, [SDCDRES]",,cont,copy,N/A,years since immigration,years since immigration,years,"[0,97]",years since immigration,Time in Canada,Length/time in Canada since imm. (D),,3.0.0,2026-02-06,active,,, +SDCDRES,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCADRES, cchs2003_m::SDCCDRES, cchs2005_m::SDCEDRES, cchs2015_2016_m::SDCDVRES, cchs2017_2018_m::SDCDVRES, [SDCDRES]",,cont,NA::a,N/A,not applicable,not applicable,years,996,not applicable,Time in Canada,Length/time in Canada since imm. (D),,3.0.0,2026-02-06,active,,, +SDCDRES,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCADRES, cchs2003_m::SDCCDRES, cchs2005_m::SDCEDRES, cchs2015_2016_m::SDCDVRES, cchs2017_2018_m::SDCDVRES, [SDCDRES]",,cont,NA::b,N/A,missing,missing,years,"[997,999]",don't know (997); refusal (998); not stated (999),Time in Canada,Length/time in Canada since imm. (D),,3.0.0,2026-02-06,active,,, +SDCDRES,N/A,cont,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCADRES, cchs2003_m::SDCCDRES, cchs2005_m::SDCEDRES, cchs2015_2016_m::SDCDVRES, cchs2017_2018_m::SDCDVRES, [SDCDRES]",,cont,NA::b,N/A,missing,missing,years,else,else,Time in Canada,Length/time in Canada since imm. (D),,3.0.0,2026-02-06,active,,, +SDCGRES,SDCGRES_cat2_1,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,1,2,0 to 9 years,0 to 9 years,N/A,1,0 to 9 years,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2026-02-06,active,,, +SDCGRES,SDCGRES_cat2_2,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,2,2,10 years or more,10 years or more,N/A,2,10 years or more,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2026-02-06,active,,, +SDCGRES,SDCGRES_cat2_NA::a,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::a,2,not applicable,not applicable,N/A,6,not applicable,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2026-02-06,active,,, +SDCGRES,SDCGRES_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,2,missing,missing,N/A,"[7,9]",don't know (7); refusal (8); not stated (9),Time in Canada,"Length/time in Canada since imm. (D, G)","CCHS 2001_p missing don't know (7), refusal (8)",2.2.0,2026-02-06,active,,, +SDCGRES,SDCGRES_cat2_NA::b,cat,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,2,missing,missing,N/A,else,else,Time in Canada,"Length/time in Canada since imm. (D, G)",,2.2.0,2026-02-06,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,4.5,N/A,0 to 9 years,0 to 9 years,years,1,0 to 9 years,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,15,N/A,10 years or more,10 years or more,years,2,10 years or more,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::a,N/A,not applicable,not applicable,years,6,not applicable,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,N/A,missing,missing,years,"[7,9]",don't know (7); refusal (8); not stated (9),Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, +SDCGRES_cont,N/A,cont,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",,cat,NA::b,N/A,missing,missing,years,else,else,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)","PUMF midpoint conversion: 0-9 years -> 4.5, 10+ years -> 15. Same databaseStart and variableStart as SDCGRES.",3.0.0,2026-02-12,active,,, SLP_02,SLP_02_cat5_1,cat,"cchs2007_2008_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SLP_010, cchs2017_2018_p::SLP_010, [SLP_02]",,cat,1,5,None of the time,None of the time,N/A,1,None of the time,Trouble sleeping,Freq. - trouble sleeping,,2.2.0,2025-11-18,active,,, SLP_02,SLP_02_cat5_2,cat,"cchs2007_2008_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SLP_010, cchs2017_2018_p::SLP_010, [SLP_02]",,cat,2,5,Little of the time,Little of the time,N/A,2,Little of the time,Trouble sleeping,Freq. - trouble sleeping,,2.2.0,2025-11-18,active,,, SLP_02,SLP_02_cat5_3,cat,"cchs2007_2008_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SLP_010, cchs2017_2018_p::SLP_010, [SLP_02]",,cat,3,5,Some of the time,Some of the time,N/A,3,Some of the time,Trouble sleeping,Freq. - trouble sleeping,,2.2.0,2025-11-18,active,,, diff --git a/inst/extdata/variables.csv b/inst/extdata/variables.csv index 9122cb9f..5685a1aa 100644 --- a/inst/extdata/variables.csv +++ b/inst/extdata/variables.csv @@ -77,7 +77,7 @@ CCC_91F,COPD,Do you have COPD?,Categorical,"cchs2005_p, cchs2007_2008_p","cchs20 COPD_Emph_der,COPD/Emphysema,COPD/Emphysema,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","DerivedVar::[DHHGAGE_cont, CCC_91E, CCC_91F], DerivedVar::[DHHGAGE_cont, CCC_091]",Chronic condition,Health status,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, DEN_132,Visited dental professional - last time,Visited dental professional - last time,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008p, cchs2009_2010_p, cchs2011_2012_p, cchs2013_2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008m, cchs2009_2010_m, cchs2011_2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::DENA_132, cchs2003_m::DENC_132, cchs2005_m::DENE_132, cchs2015_2016_m::DEN_035, cchs2017_2018_m::DEN_035, cchs2001_p::DENA_132, cchs2003_p::DENC_132, cchs2005_p::DENE_132, cchs2015_2016_p::DEN_035, cchs2017_2018_p::DEN_035, [DEN_132]",Oral Health,Dental Visits,N/A,,"Dental module was Optional Content. Ontario excluded in 2007-2008, 2011-2012, and 2015-2016.",3.0.0,,,,,active, DEPDVSEV,Depression scale - severity of depression,Depression scale - severity of depression,Categorical,"cchs2015_2016_p, cchs2017_2018_p",[DEPDVPHQ],Chronic condition,Health status,N/A,,This module is a validated instrument to measure self-reported depression. It is called PHQ-9 and was developed by Spitzer et al (1999). It was first introduced in the CCHS in 2015.,2.2.0,2025-06-30,Variable metadata completed,,,active, -DHH_AGE,Age,Age,Continuous,"cchs2009_s, cchs2010_s, cchs2012_s",[DHH_AGE],Age,Demographics,Years,,Continuous age variable for shared files,2.2.0,2025-06-30,Variable metadata completed,,,active, +DHH_AGE,Age,Age,Continuous,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2011_2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_m::DHHA_AGE, cchs2003_m::DHHC_AGE, cchs2005_m::DHHE_AGE, [DHH_AGE]",Age,Demographics,Years,,Continuous age variable for shared files,2.2.0,2025-06-30,Variable metadata completed,,,active, DHH_OWN,Home ownership,Dwelling - owned by a member of hsld,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::DHHA_OWN, cchs2003_p::DHHC_OWN, cchs2005_p::DHHE_OWN, [DHH_OWN]",Home ownership,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, DHH_SEX,Sex,Sex,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::DHHA_SEX, cchs2003_p::DHHC_SEX, cchs2005_p::DHHE_SEX, [DHH_SEX]",Sex,Demographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, DHHGAGE_5,Age,Age (20-year age groups),Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::DHHAGAGE, cchs2003_p::DHHCGAGE, cchs2005_p::DHHEGAGE, cchs2009_s::DHH_AGE, cchs2010_s::DHH_AGE, cchs2012_s::DHH_AGE, [DHHGAGE]",Age,Demographics,Years,,"5 age groups: <20, 20 to 39, 40 to 59, 60 to 79, 80+ years",2.2.0,2025-06-30,Variable metadata completed,,,active, @@ -243,8 +243,8 @@ PAYDVDYS,Active days (12-17 years old),Number of active days (12-17 years old),C PAYDVTOA,Sweat/breathe hard activities (12-17 years old),Time spent - sweat/breathe hard activities in a week (12-17 years old),Continuous,"cchs2015_2016_p, cchs2017_2018_p, cchs2015_2016_m, cchs2017_2018_m",[PAYDVTOA],Exercise,Health behaviour,minutes/week,,,2.1.0,2025-06-30,Variable metadata completed,,,active, PAYDVTTR,Active transportation (12-17 years old),Time spent - active transportation in a week (12-17 years old),Continuous,"cchs2015_2016_p, cchs2017_2018_p, cchs2019_2020_p",[PAYDVTTR],Exercise,Health behaviour,minutes/week,Extended to 2019-2020 per DDI verification,,3.0.0,2026-01-18,Added cchs2019_2020_p per L0-L4 analysis,,,active,"CEP-003: PA harmonization - 2019-2020 extension, PAADVWHO, label fixes" PAYDVVIG,Vigorous activities (12-17 years old),Time spent - vigorous activity in a week (12-17 years old),Continuous,"cchs2015_2016_p, cchs2017_2018_p, cchs2015_2016_m, cchs2017_2018_m",[PAYDVVIG],Exercise,Health behaviour,minutes/week,,,2.1.0,2025-06-30,Variable metadata completed,,,active, -pct_time_der,Percent time in Canada,Percentage of time in Canada,Continuous,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES]",Migration,Sociodemographics,%,,,2.2.0,2025-06-30,Variable metadata completed,,,active, -pct_time_der_cat10,Percent time in Canada,Categorical percentage of time in Canada,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s",DerivedVar::[pct_time_der],Migration,Sociodemographics,%,,,2.2.0,2025-06-30,Variable metadata completed,,,active, +pct_time_der,Percent time in Canada,Percentage of time in Canada,Continuous,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","DerivedVar::[DHHGAGE_cont, SDCGCBG, SDCGRES_cont, DHH_AGE, SDCGCB, SDCDRES]",Migration,Sociodemographics,%,,,2.2.0,2025-06-30,Variable metadata completed,,,active, +pct_time_der_cat10,Percent time in Canada,Categorical percentage of time in Canada,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m",DerivedVar::[pct_time_der],Migration,Sociodemographics,%,,,2.2.0,2025-06-30,Variable metadata completed,,,active, RAC_1,Difficulty activities,Has difficulty with activities,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::RACA_1, cchs2003_p::RACC_1, cchs2005_p::RACE_1, [RAC_1]",ADL,Health status,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, RAC_2A,Reduction activities at home,Reduction - activities at home,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::RACA_2A, cchs2003_p::RACC_2A, cchs2005_p::RACE_2A, [RAC_2A]",ADL,Health status,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, RAC_2B,Reduction activities at school or work,Long-term cond. reduces act. - school or work,Categorical,cchs2001_p,cchs2001_p::RACA_2B,ADL,Health status,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, @@ -275,17 +275,18 @@ REPG3,Repetitive strain injury - most serious affected body part,Repetitive stra resp_condition_der,Respiratory condition,Respiratory condition,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","DerivedVar::[DHHGAGE_cont, CCC_091, CCC_031], DerivedVar::[DHHGAGE_cont, CCC_91E, CCC_91F, CCC_91A, CCC_031], DerivedVar::[DHHGAGE_cont, CCC_091, CCC_91A, CCC_031]",Chronic condition,Health status,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDC_5A_1,Knowledge of official languages,Knowledge of official languages,Categorical,"cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SDC_025, cchs2017_2018_p::SDC_025, [SDC_5A_1]",Language,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDCDFOLS,First official language spoken,First official language spoken,Categorical,"cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SDCDVFLS, cchs2017_2018_p::SDCDVFLS, [SDCDFOLS]",Language,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, +SDCDRES,Time in Canada,Length/time in Canada since imm. (D),Continuous,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCADRES, cchs2003_m::SDCCDRES, cchs2005_m::SDCEDRES, cchs2015_2016_m::SDCDVRES, cchs2017_2018_m::SDCDVRES, [SDCDRES]",Migration,Sociodemographics,Years,,,3.0.0,2026-02-06,Variable metadata completed,,,active, SDCFIMM,Immigrant status,Immigrant Status (D),Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAFIMM, cchs2003_p::SDCCFIMM, cchs2005_p::SDCEFIMM, cchs2015_2016_p::SDCDVIMM, cchs2017_2018_p::SDCDVIMM, [SDCFIMM]",Migration,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, -SDCGCBG,Country of birth,Country of birth - (G),Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, cchs2009_s::SDCGCB, cchs2010_s::SDCGCB, cchs2012_s::SDCGCB10, [SDCGCBG]",Migration,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, -SDCGCBG_A,Country of birth,Country of birth - (G),Categorical,"cchs2009_s, cchs2010_s, cchs2012_s","cchs2012_s::SDCGCB10, [SDCGCB]",Migration,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, +SDCGCB,Country of birth,Country of birth - (G),Categorical,"cchs2001_m, cchs2003_m, cchs2005_m, cchs2007_2008_m, cchs2009_2010_m, cchs2009_m, cchs2010_m, cchs2011_2012_m, cchs2012_m, cchs2013_2014_m, cchs2015_2016_m, cchs2017_2018_m","cchs2001_m::SDCAGCB, cchs2003_m::SDCCGCB, cchs2005_m::SDCEGCB, cchs2011_2012_m::SDCGCB10, cchs2013_2014_m::SDCGCB10, cchs2015_2016_m::SDCDVCB, cchs2017_2018_m::SDCDVCB, cchs2012_s::SDCGCB10, [SDCGCB]",Migration,Sociodemographics,N/A,,,3.0.0,2026-02-06,Variable metadata completed,,,active, +SDCGCBG,Country of birth,Country of birth - (G),Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGCBG, cchs2003_p::SDCCGCBG, cchs2005_p::SDCEGCBG, cchs2011_2012_p::SDCGCB12, cchs2013_2014_p::SDCGCB13, cchs2014_p::SDCGCB13, cchs2015_2016_p::SDCDGCB, cchs2017_2018_p::SDCDGCB, [SDCGCBG]",Migration,Sociodemographics,N/A,,,2.2.0,2026-02-06,Variable metadata completed,,,active, SDCGCGT,Ethnicity,"Cultural or racial origin - (D, G)",Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAGRAC, cchs2003_p::SDCCGRAC, cchs2005_p::SDCEGCGT, cchs2015_2016_p::SDCDGCGT, cchs2017_2018_p::SDCDGCGT, cchs2009_s::SDCDCGT, cchs2010_s::SDCDCGT, cchs2012_s::SDCDCGT, [SDCGCGT]",Ethnicity,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDCGCGT_A,Ethnicity,"Cultural or racial origin - (D, G)",Categorical,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDCGT],Ethnicity,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDCGLHM,Language(s) spoken at home,Language(s) spoken at home,Categorical,"cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2015_2016_p::SDCDGLHM, cchs2017_2018_p::SDCDGLHM, cchs2009_s::SDCDLHM, cchs2010_s::SDCDLHM, cchs2012_s::SDCDLHM, [SDCGLHM]",Language,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDCGLHM_A,Language(s) spoken at home,Language(s) spoken at home,Categorical,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDLHM],Language,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDCGLNG,Languages - can converse in,Languages - can converse in,Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2009_s, cchs2010_s","cchs2001_p::SDCAGLNG, cchs2003_p::SDCCGLNG, cchs2005_p::SDCEGLNG, cchs2009_s::SDCDLNG, cchs2010_s::SDCDLNG, [SDCGLNG]",Language,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SDCGLNG_A,Languages - can converse in,Languages - can converse in,Categorical,"cchs2009_s, cchs2010_s",[SDCDLNG],Language,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, -SDCGRES,Time in Canada,"Length/time in Canada since imm. (D, G)",Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2009_s, cchs2010_s, cchs2012_s","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, cchs2009_s::SDCDRES, cchs2010_s::SDCDRES, cchs2012_s::SDCDRES, [SDCGRES]",Migration,Sociodemographics,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, -SDCGRES_A,Time in Canada,"Length/time in Canada since imm. (D, G)",Continuous,"cchs2009_s, cchs2010_s, cchs2012_s",[SDCDRES],Migration,Sociodemographics,Years,,,2.2.0,2025-06-30,Variable metadata completed,,,active, +SDCGRES,Time in Canada,"Length/time in Canada since imm. (D, G)",Categorical,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",Migration,Sociodemographics,N/A,,,2.2.0,2026-02-06,Variable metadata completed,,,active, +SDCGRES_cont,Time in Canada (cont),"Length/time in Canada since imm. - continuous midpoint (D, G)",Continuous,"cchs2001_p, cchs2003_p, cchs2005_p, cchs2007_2008_p, cchs2009_2010_p, cchs2010_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p","cchs2001_p::SDCAGRES, cchs2003_p::SDCCGRES, cchs2005_p::SDCEGRES, cchs2015_2016_p::SDCDGRES, cchs2017_2018_p::SDCDGRES, [SDCGRES]",Migration,Sociodemographics,years,"PUMF midpoint conversion from SDCGRES categorical (0-9 years -> 4.5, 10+ years -> 15).",,3.0.0,2026-02-12,,,,active, SLP_02,Trouble sleeping,Freq. - trouble sleeping,Categorical,"cchs2007_2008_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SLP_010, cchs2017_2018_p::SLP_010, [SLP_02]",Sleep,Health behaviour,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SLP_02_A,Trouble sleeping,Freq. - trouble sleeping,Categorical,cchs2001_p,[GENA_04],Sleep,Health behaviour,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, SLP_03,Sleep refreshing,Freq. - find sleep refreshing,Categorical,"cchs2007_2008_p, cchs2011_2012_p, cchs2012_p, cchs2013_2014_p, cchs2014_p, cchs2015_2016_p, cchs2017_2018_p, cchs2012_s","cchs2015_2016_p::SLP_015, cchs2017_2018_p::SLP_015, [SLP_03]",Sleep,Health behaviour,N/A,,,2.2.0,2025-06-30,Variable metadata completed,,,active, diff --git a/man/calculate_pct_time.Rd b/man/calculate_pct_time.Rd new file mode 100644 index 00000000..60037b67 --- /dev/null +++ b/man/calculate_pct_time.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/percent-time-canada.R +\name{calculate_pct_time} +\alias{calculate_pct_time} +\title{Calculate percent time in Canada} +\usage{ +calculate_pct_time(age, born_in_canada, years_in_canada) +} +\arguments{ +\item{age}{continuous age variable.} + +\item{born_in_canada}{whether or not someone was born in Canada +(1 - born in Canada, 2 - born outside Canada).} + +\item{years_in_canada}{continuous years in Canada. For PUMF data, this is +derived from the categorical SDCGRES via midpoint conversion in +variable_details.csv. For master data, this is the actual continuous +years from SDCDRES.} +} +\value{ +Numeric value between 0 and 100 that represents percentage of a + respondent's time in Canada. Returns \code{tagged_na("b")} for invalid or + missing inputs. +} +\description{ +Calculates the percentage of a respondent's life spent in + Canada. Used by pct_time_der for both PUMF and master databases. The + worksheet maps different feeder variables for each database type, but + the calculation is the same: for respondents born outside Canada, + percent time = years in Canada / age * 100. + + For PUMF data, the categorical time-in-Canada variable (SDCGRES) is + converted to continuous midpoints upstream via the SDCGRES_cont intermediate + variable in variable_details.csv (1 = 4.5 years, 2 = 15 years). For master + data, continuous years (SDCDRES) are passed directly. +} +\examples{ +# Using rec_with_table() across CCHS cycles (PUMF) +library(cchsflow) +pct_time2009_2010 <- rec_with_table( + cchs2009_2010_p, c( + "DHHGAGE_cont", "SDCGCBG", + "SDCGRES_cont", "pct_time_der" + ) +) +head(pct_time2009_2010) + +pct_time2011_2012 <- rec_with_table( + cchs2011_2012_p, c( + "DHHGAGE_cont", "SDCGCBG", + "SDCGRES_cont", "pct_time_der" + ) +) +tail(pct_time2011_2012) + +combined_pct_time <- merge_rec_data(pct_time2009_2010, pct_time2011_2012) +head(combined_pct_time) +tail(combined_pct_time) + +# Scalar usage (pass continuous years directly) +calculate_pct_time(age = 27, born_in_canada = 2, years_in_canada = 4.5) + +# Vector usage +calculate_pct_time( + age = c(27, 40, 35), + born_in_canada = c(2, 1, 2), + years_in_canada = c(4.5, 4.5, 15) +) +} diff --git a/man/categorize_pct_time.Rd b/man/categorize_pct_time.Rd new file mode 100644 index 00000000..be81060a --- /dev/null +++ b/man/categorize_pct_time.Rd @@ -0,0 +1,62 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/percent-time-canada.R +\name{categorize_pct_time} +\alias{categorize_pct_time} +\title{Categorize percent time in Canada} +\usage{ +categorize_pct_time(pct_time_der) +} +\arguments{ +\item{pct_time_der}{derived continuous percent time in Canada. +See \code{\link{calculate_pct_time}} for documentation on how variable was +derived.} +} +\value{ +Character value for categorical percent time in Canada ("1" through +"10"), "NA(a)" for not applicable, or "NA(b)" for missing/invalid inputs. +} +\description{ +Categorizes the derived percent time in Canada variable +(pct_time_der) into 10 percent intervals for pct_time_der_cat10. +} +\details{ +The percent time in Canada provides an estimated percentage of the +time a person's life was spent in Canada. The categorical percent time in +Canada divides the continuous value into 10 percent intervals. + +pct_time_der_cat10 uses the derived variable pct_time_der. pct_time_der uses +various variables that have been transformed by cchsflow (see documentation +on pct_time_der). In order to categorize percent time in Canada across CCHS +cycles, the variables must be transformed and harmonized. +} +\examples{ +# Using rec_with_table() across CCHS cycles +library(cchsflow) +pct_time_cat2009_2010 <- rec_with_table( + cchs2009_2010_p, c( + "DHHGAGE_cont", "SDCGCBG", + "SDCGRES_cont", "pct_time_der", "pct_time_der_cat10" + ) +) +head(pct_time_cat2009_2010) + +pct_time_cat2011_2012 <- rec_with_table( + cchs2011_2012_p, c( + "DHHGAGE_cont", "SDCGCBG", + "SDCGRES_cont", "pct_time_der", "pct_time_der_cat10" + ) +) +tail(pct_time_cat2011_2012) + +combined_pct_time_cat <- merge_rec_data(pct_time_cat2009_2010, +pct_time_cat2011_2012) +head(combined_pct_time_cat) +tail(combined_pct_time_cat) + +# Scalar usage +categorize_pct_time(55.5) + +# Vector usage +categorize_pct_time(c(5, 25, 55, 85, 100)) + +} diff --git a/man/pct_time_fun.Rd b/man/pct_time_fun.Rd deleted file mode 100644 index 2b97b02e..00000000 --- a/man/pct_time_fun.Rd +++ /dev/null @@ -1,74 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/percent-time-canada.R -\name{pct_time_fun} -\alias{pct_time_fun} -\title{Percent time in Canada} -\usage{ -pct_time_fun(DHHGAGE_cont, SDCGCBG, SDCGRES) -} -\arguments{ -\item{DHHGAGE_cont}{continuous age variable.} - -\item{SDCGCBG}{whether or not someone was born in Canada (1 - born in Canada, -2 - born outside Canada)} - -\item{SDCGRES}{how long someone has lived in Canada. Note: in the PUMF CCHS -datasets, this is a categorical variable with two categories (1 - 0-9 years; -2 - 10+ years).} -} -\value{ -Numeric value between 0 and 100 that represents - percentage of a respondent's time in Canada -} -\description{ -This function creates a derived variable (pct_time_der) that - provides an estimated percentage of the time a person's life was spent in - Canada. -} -\note{ -Since SDCGRES is a categorical variable measuring length of time, we've - set midpoints in the function. A respondent identified as being in Canada - for 0-9 years is assigned a value of 4.5 years, and someone who has been in - Canada for over 10 years is assigned a value of 15 years. -} -\examples{ -# Using pct_time_fun() to create percent time values between CCHS cycles -# pct_time_fun() is specified in variable_details.csv along with the CCHS -# variables and cycles included. - -# To transform pct_time_der across cycles, use rec_with_table() for each CCHS -# cycle and specify pct_time_der, along with age (DHHGAGE_cont), whether or -# not someone was born in Canada (SDCGCBG), how long someone has lived in -# Canada (SDCGRES). Then by using merge_rec_data(), you can combine -# pct_time_der across cycles - -library(cchsflow) -pct_time2009_2010 <- rec_with_table( - cchs2009_2010_p, c( - "DHHGAGE_cont", "SDCGCBG", - "SDCGRES", "pct_time_der" - ) -) -head(pct_time2009_2010) - -pct_time2011_2012 <- rec_with_table( - cchs2011_2012_p, c( - "DHHGAGE_cont", "SDCGCBG", - "SDCGRES", "pct_time_der" - ) -) -tail(pct_time2011_2012) - -combined_pct_time <- merge_rec_data(pct_time2009_2010, pct_time2011_2012) -head(combined_pct_time) -tail(combined_pct_time) - -# Using pct_time_fun() to generate a value for percent time spent in Canada -# with user inputted values Let's say you are 27 years old who was born -# outside of Canada and have been living in Canada for less than 10 years. -# Your estimated percent time spent in Canada can be calculated as follows: - -pct_time <- pct_time_fun(DHHGAGE_cont = 27, SDCGCBG = 2, SDCGRES = 1) - -print(pct_time) -} diff --git a/man/pct_time_fun_cat.Rd b/man/pct_time_fun_cat.Rd deleted file mode 100644 index 43d6e17b..00000000 --- a/man/pct_time_fun_cat.Rd +++ /dev/null @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/percent-time-canada.R -\name{pct_time_fun_cat} -\alias{pct_time_fun_cat} -\title{Categorical percent time in Canada} -\usage{ -pct_time_fun_cat(pct_time_der) -} -\arguments{ -\item{pct_time_der}{derived continuous percent time in Canada. -See \code{\link{pct_time_fun}} for documentation on how variable was derived.} -} -\value{ -value for categorical percent time in Canada using pct_time_der -variable. -} -\description{ -This function creates a categorical derived variable -(pct_time_der_cat10) that categorizes the derived percent time in Canada -variable (pct_time_der). -} -\details{ -The percent time in Canada provides an estimated percentage of the -time a person's life was spent in Canada.The categorical percent time in -Canada divides the continuous value into 10 percent intervals. - -pct_time_der_cat10 uses the derived variable pct_time_der. pct_time_der uses -various variables that have been transformed by cchsflow (see documentation -on pct_time_der). In order to categorize percent time in Canada across CCHS -cycles, the variables must be transformed and harmonized. -} -\examples{ -# Using pct_time_fun_cat() to create categorical percent time values -# between CCHS cycles. -# pct_time_fun_cat() is specified in variable_details.csv along with the CCHS -# variables and cycles included. - -# To transform pct_time_der_cat10 across cycles, use rec_with_table() for -# each CCHS cycle. -# Since pct_time_der is a derived variable, you will have to specify the -# variables that are derived from it. -# Then by using merge_rec_data(), you can combine pct_time_der_cat10 across -# cycles. - -library(cchsflow) -pct_time_cat2009_2010 <- rec_with_table( - cchs2009_2010_p, c( - "DHHGAGE_cont", "SDCGCBG", - "SDCGRES", "pct_time_der", "pct_time_der_cat10" - ) -) -head(pct_time_cat2009_2010) - -pct_time_cat2011_2012 <- rec_with_table( - cchs2011_2012_p, c( - "DHHGAGE_cont", "SDCGCBG", - "SDCGRES", "pct_time_der", "pct_time_der_cat10" - ) -) -tail(pct_time_cat2011_2012) - -combined_pct_time_cat <- merge_rec_data(pct_time_cat2009_2010, -pct_time_cat2011_2012) -head(combined_pct_time_cat) -tail(combined_pct_time_cat) - -} diff --git a/tests/testthat/test-immigration.R b/tests/testthat/test-immigration.R index 70ff315f..e8d78540 100644 --- a/tests/testthat/test-immigration.R +++ b/tests/testthat/test-immigration.R @@ -1,46 +1,100 @@ -# pct_time_fun +# calculate_pct_time (unified — continuous years in Canada) -test_that("pct_time_fun has expected output when age is out of range", { - expect_equal(pct_time_fun(-1, 2, 1), tagged_na("b")) +test_that("calculate_pct_time returns 100 when born in Canada", { + expect_equal(calculate_pct_time(27, 1, 4.5), 100) }) -test_that("pct_time_fun has expected output when +test_that("calculate_pct_time has expected output when age is out of range", { + expect_equal(calculate_pct_time(-1, 2, 4.5), tagged_na("b")) +}) + +test_that("calculate_pct_time has expected output when immigrant status is out of range", { - expect_equal(pct_time_fun(20, 3, 1), tagged_na("b")) + expect_equal(calculate_pct_time(20, 3, 4.5), tagged_na("b")) +}) + +test_that("calculate_pct_time has expected output when + time in Canada is NA", { + expect_equal(calculate_pct_time(20, 2, NA), tagged_na("b")) +}) + +test_that("calculate_pct_time has expected output with 0-9 year midpoint", { + expect_equal(calculate_pct_time(20, 2, 4.5), 22.5) +}) + +test_that("calculate_pct_time has expected output with 10+ year midpoint", { + expect_equal(calculate_pct_time(20, 2, 15), 75) +}) + +test_that("calculate_pct_time has expected output with master continuous years", { + expect_equal(calculate_pct_time(20, 2, 10), 50) }) -test_that("pct_time_fun has expected output when - time in Canada is out of range", { - expect_equal(pct_time_fun(20, 2, 3), tagged_na("b")) +test_that("calculate_pct_time has expected output when age is NA", { + expect_equal(calculate_pct_time(NA, 2, 4.5), tagged_na("b")) }) -test_that("pct_time_fun has expected output when all arguments are in range", { - expect_equal(pct_time_fun(20, 2, 1), 22.5) +test_that("calculate_pct_time has expected output when immigrant status is NA", { + expect_equal(calculate_pct_time(20, NA, 4.5), tagged_na("b")) }) -test_that("pct_time_fun has expected output when age is NA", { - expect_equal(pct_time_fun(NA, 2, 1), tagged_na("b")) +test_that("calculate_pct_time has expected output when all arguments are NA", { + expect_equal(calculate_pct_time(NA, NA, NA), tagged_na("b")) }) -test_that("pct_time_fun has expected output when immigrant status is NA", { - expect_equal(pct_time_fun(20, NA, 1), tagged_na("b")) +test_that("calculate_pct_time works with vector inputs (PUMF midpoints)", { + result <- calculate_pct_time( + age = c(20, 40, 30), + born_in_canada = c(2, 1, 2), + years_in_canada = c(4.5, 4.5, 15) + ) + expect_equal(result[1], 22.5) + expect_equal(result[2], 100) + expect_equal(result[3], 50) }) -test_that("pct_time_fun has expected output when time in Canada is NA", { - expect_equal(pct_time_fun(20, 2, NA), tagged_na("b")) +test_that("calculate_pct_time returns tagged_na(b) when result exceeds 100", { + # years_in_canada > age → impossible percentage + expect_equal(calculate_pct_time(20, 2, 25), tagged_na("b")) }) -test_that("pct_time_fun has expected output when all arguments are NA", { - expect_equal(pct_time_fun(NA, NA, NA), tagged_na("b")) +test_that("calculate_pct_time returns 100 at exact boundary", { + # years_in_canada == age → exactly 100% + expect_equal(calculate_pct_time(20, 2, 20), 100) }) -# pct_time_fun_cat -test_that("pct_time_fun_cat has expected output when input is out of range", { - expect_equal(pct_time_fun_cat(-1), "NA(b)") +test_that("calculate_pct_time works with vector inputs (master continuous)", { + result <- calculate_pct_time( + age = c(20, 40, 30), + born_in_canada = c(2, 1, 2), + years_in_canada = c(10, 20, 5) + ) + expect_equal(result[1], 50) + expect_equal(result[2], 100) + expect_length(result, 3) }) -test_that("pct_time_fun_cat has expected output when input is in range", { - expect_equal(pct_time_fun_cat(1), 1) +# categorize_pct_time + +test_that("categorize_pct_time has expected output when input is out of range", { + expect_equal(categorize_pct_time(-1), "NA(b)") +}) + +test_that("categorize_pct_time has expected output when input is in range", { + expect_equal(categorize_pct_time(1), "1") +}) + +test_that("categorize_pct_time returns 10 at upper boundary", { + expect_equal(categorize_pct_time(100), "10") +}) + +test_that("categorize_pct_time handles tagged_na(a)", { + expect_equal(categorize_pct_time(tagged_na("a")), "NA(a)") +}) + +test_that("categorize_pct_time works with vector inputs", { + result <- categorize_pct_time(c(5, 25, 55, 85, 100)) + expect_equal(result, c("1", "3", "6", "9", "10")) }) # immigration_fun @@ -62,4 +116,4 @@ test_that("immigration_fun has expected output when SDCGRES is out of range", { test_that("immigration_fun has expected output when all values are in range", { expect_equal(immigration_fun(1,2, 2, 1), 4) -}) \ No newline at end of file +})