Hello everyone,
Have been trying to generate a variable that combines value from two measurements that derived from questionnaire and the lab test itself together.
What I would like to do is to combine the values from these two variables (current_smoker and cot at 26wk) together as one variable – tobacco_exposure as yes (1) or no (0)
So have been trying several codes so as to combine those values together, but I somehow still quite confused with the commands I used for this task .
Those commands are :
gen tobacco_exposure=.
replace tobacco_expo=0 if (cot_26wk!=.&cot_26wk==0)|(smoking!=.&smoking==0)
replace tobacco_expo=0 if (cot_26wk!=.&cot_26wk==0 & smoking!=.&smoking==0)
replace tobacco_expo=1 if (cot_26wk!=.&cot_26wk>0 & smoking!=.& smoking!=.&smoking==1)
replace tobacco_5=1 if (cot_26wk!=.&cot_26wk>0)|(smoking!=.&smoking==1)
In this case, may I know what is the difference when I have “&” and “I” as the “conjunction” in between those brackets?
Many thanks for the clarification in advance and Have a lovely day! J
Em
Have been trying to generate a variable that combines value from two measurements that derived from questionnaire and the lab test itself together.
- Current smoker – categorical variable, which has been coded as yes (1) or No (0)
- Cotinine at 26 week – continuous variable (either it is 0 or 0 above, for example, 0.19 or 0.65 ng/mL)
What I would like to do is to combine the values from these two variables (current_smoker and cot at 26wk) together as one variable – tobacco_exposure as yes (1) or no (0)
So have been trying several codes so as to combine those values together, but I somehow still quite confused with the commands I used for this task .
Those commands are :
gen tobacco_exposure=.
replace tobacco_expo=0 if (cot_26wk!=.&cot_26wk==0)|(smoking!=.&smoking==0)
replace tobacco_expo=0 if (cot_26wk!=.&cot_26wk==0 & smoking!=.&smoking==0)
replace tobacco_expo=1 if (cot_26wk!=.&cot_26wk>0 & smoking!=.& smoking!=.&smoking==1)
replace tobacco_5=1 if (cot_26wk!=.&cot_26wk>0)|(smoking!=.&smoking==1)
In this case, may I know what is the difference when I have “&” and “I” as the “conjunction” in between those brackets?
Many thanks for the clarification in advance and Have a lovely day! J
Em
Comment