This function creates a continuous derived variable (SMKG040_fun) that calculates the approximate age that a daily or former daily smoker began smoking daily.

SMKG040_fun(SMKG203_cont, SMKG207_cont)

Arguments

SMKG203_cont

age started smoking daily. Variable asked to daily smokers.

SMKG207_cont

age started smoking daily. Variable asked to former daily smokers.

Value

value for age started smoking daily for daily/former daily smokers in the SMKG040_cont

Details

SMKG203 (daily smoker) and SMKG207 (former daily) are present in CCHS 2001-2014, and are separate variables. For CCHS 2015 and onward, SMKG040 (daily/former daily) combines the two previous variables. SMKG040_fun takes the continuous functions (SMKG203_cont and SMKG207_cont) to create SMKG040 for 2001-2014.

Note

In previous cycles, both SMKG203 and SMKG207 included respondents who did not state their smoking status. From CCHS 2015 and onward, SMKG040 only included respondents who specified daily smoker or former daily smoker. As a result, SMKG040 has a large number of missing respondents for CCHS 2015 survey cycles and onward.

Examples

 
# Using SMKG040_fun() to create age values across CCHS cycles
# SMKG040_fun() is specified in variable_details.csv under SMKG040_cont.

# To create a continuous harmonized variable for SMKG040, use rec_with_table() 
# for each CCHS cycle and specify SMKG040_cont.

library(cchsflow)

age_smoke_dfd_2009_2010 <- rec_with_table(
  cchs2009_2010_p, c(
    "SMKG203_cont", "SMKG207_cont","SMKG040_cont"
  )
)
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data

head(age_smoke_dfd_2009_2010)
#>   SMKG203_cont SMKG207_cont SMKG040_cont
#> 1           NA           NA           NA
#> 2           NA           NA           NA
#> 3           NA           NA           NA
#> 4           NA         18.5         18.5
#> 5           NA         16.0         16.0
#> 6           NA          8.0          8.0

age_smoke_dfd_2011_2012 <- rec_with_table(
  cchs2011_2012_p,c(
    "SMKG203_cont", "SMKG207_cont","SMKG040_cont"
  )
)
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data

tail(age_smoke_dfd_2011_2012)
#>     SMKG203_cont SMKG207_cont SMKG040_cont
#> 195           NA           16           16
#> 196           NA           NA           NA
#> 197           NA           NA           NA
#> 198           NA           16           16
#> 199           NA           NA           NA
#> 200           16           NA           16

combined_age_smoke_dfd <- suppressWarnings(merge_rec_data
(age_smoke_dfd_2009_2010,age_smoke_dfd_2011_2012))

head(combined_age_smoke_dfd)
#>   SMKG203_cont SMKG207_cont SMKG040_cont
#> 1           NA           NA           NA
#> 2           NA           NA           NA
#> 3           NA           NA           NA
#> 4           NA         18.5         18.5
#> 5           NA         16.0         16.0
#> 6           NA          8.0          8.0
tail(combined_age_smoke_dfd)
#>     SMKG203_cont SMKG207_cont SMKG040_cont
#> 395           NA           16           16
#> 396           NA           NA           NA
#> 397           NA           NA           NA
#> 398           NA           16           16
#> 399           NA           NA           NA
#> 400           16           NA           16