Hello everyone,
I hope you're all fine.
I have a question which took me so long, and I couldn't find a way to execute
Let's suppose that I have the following command:
foreach var of varlist recurrence_status anemia_cat decreased_Plt_cat
increased_creat_cat hypernatremia_cat hyponatremia_cat
hyperkalemia_cat hypokalemia_cat increased_bilirubin_cat
increased_ALT_cat increased_AST_cat increased_ap_cat
decreased_WBC_cat {
if `var'== hyperkalemia_cat | `var'== recurrence_status {
local 1 hyperkalemia_cat
local 2 recurrence_status
logistic `1' rs1695 age
logistic `1' rs11615 age
logistic `1' rs2228001 age
logistic `2' rs1695 age
logistic `2' rs11615 age
logistic `2' rs2228001 age
}
else if `var' ==anemia_cat {
local 3 anemia_cat
logistic `3' rs1695 BMI
logistic `3' rs11615 BMI
logistic `3' rs2228001 BMI
}
else if `var' =! hyperkalemia_cat | `var' !=recurrence_status | `var' !=anemia_cat
logistic `var' rs1695
logistic `var' rs11615
logistic `var' rs2228001
}
I want the foreach loop to run the the logistic regression command with age adjustment if the variables are recurrence_status or hyperkalemia_cat
and to run the the logistic regression command with BMI adjustment if the variable is anemia_cat
otherwise, run the foreach command for all the remaining variables without adjustment
How can I do this using if or while or any other loop that might help ?
I hope you're all fine.
I have a question which took me so long, and I couldn't find a way to execute
Let's suppose that I have the following command:
foreach var of varlist recurrence_status anemia_cat decreased_Plt_cat
increased_creat_cat hypernatremia_cat hyponatremia_cat
hyperkalemia_cat hypokalemia_cat increased_bilirubin_cat
increased_ALT_cat increased_AST_cat increased_ap_cat
decreased_WBC_cat {
if `var'== hyperkalemia_cat | `var'== recurrence_status {
local 1 hyperkalemia_cat
local 2 recurrence_status
logistic `1' rs1695 age
logistic `1' rs11615 age
logistic `1' rs2228001 age
logistic `2' rs1695 age
logistic `2' rs11615 age
logistic `2' rs2228001 age
}
else if `var' ==anemia_cat {
local 3 anemia_cat
logistic `3' rs1695 BMI
logistic `3' rs11615 BMI
logistic `3' rs2228001 BMI
}
else if `var' =! hyperkalemia_cat | `var' !=recurrence_status | `var' !=anemia_cat
logistic `var' rs1695
logistic `var' rs11615
logistic `var' rs2228001
}
I want the foreach loop to run the the logistic regression command with age adjustment if the variables are recurrence_status or hyperkalemia_cat
and to run the the logistic regression command with BMI adjustment if the variable is anemia_cat
otherwise, run the foreach command for all the remaining variables without adjustment
How can I do this using if or while or any other loop that might help ?
Comment