This function creates a derived variable (pack_years_der) that measures an individual's smoking pack-years based on various CCHS smoking variables. This is a popular variable used by researchers to quantify lifetime exposure to cigarette use.
pack_years_fun( SMKDSTY_A, DHHGAGE_cont, time_quit_smoking, SMKG203_cont, SMKG207_cont, SMK_204, SMK_05B, SMK_208, SMK_05C, SMKG01C_cont, SMK_01A )
SMKDSTY_A | variable used in CCHS cycles 2001-2014 that classifies an individual's smoking status. |
---|---|
DHHGAGE_cont | continuous age variable. |
time_quit_smoking | derived variable that calculates the approximate
time a former smoker has quit smoking.
See |
SMKG203_cont | age started smoking daily. Variable asked to daily smokers. |
SMKG207_cont | age started smoking daily. Variable asked to former daily smokers. |
SMK_204 | number of cigarettes smoked per day. Variable asked to daily smokers. |
SMK_05B | number of cigarettes smoked per day. Variable asked to occasional smokers |
SMK_208 | number of cigarettes smoked per day. Variable asked to former daily smokers |
SMK_05C | number of days smoked at least one cigarette |
SMKG01C_cont | age smoked first cigarette |
SMK_01A | smoked 100 cigarettes in lifetime (y/n) |
value for smoking pack-years in the pack_years_der variable
pack-years is calculated by multiplying the number of cigarette packs per day (20 cigarettes per pack) by the number of years. Example 1: a respondent who is a current smoker who smokes 1 package of cigarettes for the last 10 years has smoked 10 pack-years. Pack-years is also calculated for former smokers. Example 2: a respondent who started smoking at age 20 years and smoked half a pack of cigarettes until age 40 years smoked for 10 pack-years.
# Using pack_years_fun() to create pack-years values across CCHS cycles # pack_years_fun() is specified in variable_details.csv along with the CCHS # variables and cycles included. # To transform pack_years_der across cycles, use rec_with_table() for each # CCHS cycle and specify pack_years_der, along with each smoking variable. # Since time_quit_smoking_der is also a derived # variable, you will have to specify the variables that are derived from it. # Then by using merge_rec_data(), you can combine pack_years_der across # cycles library(cchsflow) pack_years2009_2010 <- rec_with_table( cchs2009_2010_p, c( "SMKDSTY_A", "DHHGAGE_cont", "SMK_09A_B", "SMKG09C", "time_quit_smoking", "SMKG203_cont", "SMKG207_cont", "SMK_204", "SMK_05B", "SMK_208", "SMK_05C", "SMK_01A", "SMKG01C_cont", "pack_years_der" ) )#>#>#>#>#>#>#>#>#>#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 1 13 2 NA NA NA(a) NA NA 6 #> 2 27 2 NA NA NA(a) NA NA 6 #> 3 62 2 NA NA NA(a) NA NA 5 #> 4 52 1 NA NA 4 NA 20 4 #> 5 67 1 NA NA 4 NA 35 4 #> 6 62 1 NA NA 4 NA 25 4 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 1 NA NA(a) NA NA NA #> 2 NA NA(a) NA NA NA #> 3 16 NA(a) NA NA NA #> 4 16 2 NA 18.5 8 #> 5 16 3 NA 16.0 12 #> 6 8 3 NA 8.0 12 #> pack_years_der #> 1 0.000 #> 2 0.000 #> 3 0.007 #> 4 25.500 #> 5 68.250 #> 6 52.500pack_years2011_2012 <- rec_with_table( cchs2011_2012_p,c( "SMKDSTY_A", "DHHGAGE_cont", "SMK_09A_B", "SMKG09C", "time_quit_smoking", "SMKG203_cont", "SMKG207_cont", "SMK_204", "SMK_05B", "SMK_208", "SMK_05C", "SMK_01A", "SMKG01C_cont", "pack_years_der" ) )#>#>#>#>#>#>#>#>#>#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 195 72.0 1 NA NA 4 NA 3 4 #> 196 22.0 2 NA NA NA(a) NA NA 5 #> 197 18.5 2 NA NA NA(a) NA NA 6 #> 198 42.0 1 NA NA 4 NA 10 4 #> 199 62.0 1 NA NA NA(a) 20 NA 1 #> 200 52.0 1 NA NA NA(a) 13 NA 1 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 195 16 3 NA 16 12 #> 196 13 NA(a) NA NA NA #> 197 NA NA(a) NA NA NA #> 198 16 2 NA 16 8 #> 199 16 NA(a) NA NA NA #> 200 13 NA(a) 16 NA NA #> pack_years_der #> 195 6.600 #> 196 0.007 #> 197 0.000 #> 198 9.000 #> 199 NA #> 200 23.400combined_pack_years <- suppressWarnings(merge_rec_data(pack_years2009_2010, pack_years2011_2012)) head(combined_pack_years)#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 1 13 2 NA NA NA(a) NA NA 6 #> 2 27 2 NA NA NA(a) NA NA 6 #> 3 62 2 NA NA NA(a) NA NA 5 #> 4 52 1 NA NA 4 NA 20 4 #> 5 67 1 NA NA 4 NA 35 4 #> 6 62 1 NA NA 4 NA 25 4 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 1 NA NA(a) NA NA NA #> 2 NA NA(a) NA NA NA #> 3 16 NA(a) NA NA NA #> 4 16 2 NA 18.5 8 #> 5 16 3 NA 16.0 12 #> 6 8 3 NA 8.0 12 #> pack_years_der #> 1 0.000 #> 2 0.000 #> 3 0.007 #> 4 25.500 #> 5 68.250 #> 6 52.500#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 395 72.0 1 NA NA 4 NA 3 4 #> 396 22.0 2 NA NA NA(a) NA NA 5 #> 397 18.5 2 NA NA NA(a) NA NA 6 #> 398 42.0 1 NA NA 4 NA 10 4 #> 399 62.0 1 NA NA NA(a) 20 NA 1 #> 400 52.0 1 NA NA NA(a) 13 NA 1 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 395 16 3 NA 16 12 #> 396 13 NA(a) NA NA NA #> 397 NA NA(a) NA NA NA #> 398 16 2 NA 16 8 #> 399 16 NA(a) NA NA NA #> 400 13 NA(a) 16 NA NA #> pack_years_der #> 395 6.600 #> 396 0.007 #> 397 0.000 #> 398 9.000 #> 399 NA #> 400 23.400