Hi there, I'm trying to make a new variable that will convert a variable to a new variable representing packs of cigarettes smoked per week and am having some issues. I have run this code several times and checked the log and it has no errors, but for some reason when I run a proc freq on it it only gives shows me the values for values that were already in cigarettes/week values. Some context. The original variables (q6_4 and q6_10) were coded as follows: The first digit of the answer identifies the unit (1 represent day, 2 represent week, etc.), the next two digits was the number smoked during that unit of time frame. This is coded as a categorical variable. _ _ _ Enter number of cigarettes 1 pack = 20 cigarettes 101 ‑ 199 Number per day 201 ‑ 299 Number per week 301 ‑ 399 Number per month 401 ‑ 499 Number per year 888 Don't Know/Not Sure 999 Refused What I tried to do is convert them to numeric, and then use that numerical variable to calculate packs smoked per week for all the individuals who smoke any amount of cigarettes. Calculations are as follows Convert cigarettes/day to cigarettes/week: (cigarettes/day)*7 Convert cigarettes/month to cigarettes/week: (cigarettes/month)/4.345 (4.345 weeks in a month on average) Convert cigarettes/year to cigarettes/week: (cigarettes/year)/52 The code I am using is below: *Convert smoking variables to numeric; if q6_4 ne "" and smoke_stat = 1 then numerical_smoke = input(q6_4, 4.); else if q6_10 ne "" and smoke_stat = 1 then numerical_smoke = input(q6_10, 4.); else numerical_smoke = 0; *Make variable for current packs per week at baseline; if numerical_smoke gt 100 and numerical_smoke lt 200 then cig_perweek = ((numerical_smoke - 100)*7); else if numerical_smoke gt 200 and numerical_smoke lt 300 then cig_perweek = (numerical_smoke - 200); else if numerical_smoke gt 300 and numerical_smoke lt 400 then cig_perweek = ((numerical_smoke - 300)/4.345); else if numerical_smoke gt 400 and numerical_smoke lt 500 then cig_perweek = ((numerical_smoke - 400)/52); else cig_perweek = 0; *Create pack per week variable; pack_perweek = cig_perweek/20; I honestly don't know why it won't show me the full range of values I've asked for. Any ideas? Thanks!
... View more