Hello again. I want to run a logistic regression. My dependent variable is Mets and independent variable is Q (Quartiles of Dietary Inflammatory Index) (coded as 1,2,3,4) My covariates are age, Energy intake,BMI, education (coded 0, 1, 2), Alcohol(0,1), exercise (0,1),smoking(o,1) and physical exercise (0,1).
proc surveylogistic data = Project1.DII_M;
weight pooled_wt;
cluster psu;
strata kstrata;
class Q (reference = '1') educn(reference='2') smoking (reference='0') exercise (reference='1') Drinking (reference='0');
model Mets (desc) = age HE_BMI educn Drinking smoking exercise N_EN Q;
Domain sex;
run;
I then want to calculate p for trend. To do this, I assigned the median value (Q_median) of the variable Adj_DII in each quartile category to each participant and modeled this as a continuous variable and read off the pr>t as my p for trend.
I used the following code to determine median values, assigning them to participants and running a logistic regression.
/*obtaining median in each quartile*/
proc report data=Project1.DII_Q out=dii_median;
columns sex Q Adj_DII;
define sex / group "Sexe";
define Q / group "Quartile";
define Adj_DII / median;
run;
/*Assigning median value to individuals*/
data Project1.DII_M;
set Project1.DII_Q;
if sex=1 and Q=1 then Q_median=-1.10;
else if sex=1 and Q=2 then Q_median=0.13;
else if sex=1 and Q=3 then Q_median=1.13;
else if sex=1 and Q=4 then Q_median=2.27;
else if sex=2 and Q=1 then Q_median=-1.22;
else if sex=2 and Q=2 then Q_median=0.10;
else if sex=2 and Q=3 then Q_median=1.06;
else if sex=2 and Q=4 then Q_median=2.06;
if HE_BMI LE 18.5 then BMI_cat=0;
else if 18.5 LT HE_BMI LT 23 then BMI_cat=1;
else if 23 LT HE_BMI LT 25 then BMI_cat=2;
else if HE_BMI GE 25 then BMI_cat=3;
Keep Age sex pooled_wt kstrata psu HE_BMI educn Drinking smoking exercise N_EN Q
Mets Hy_glu Abd_obs TG_high Low_HDL HTN Q_median Adj_DII BMI_cat ;
run;
/*obtaining p for trend..(method adopted from some paper*/
proc surveylogistic data = Project1.DII_M;
weight pooled_wt;
cluster psu;
strata kstrata;
model Mets(desc) = age HE_BMI educn Drinking smoking exercise N_EN Q_median;
Domain sex;
run;
The p for trend obtained in this paper was 0.008 whereas mine is 0.09 so far from this value. I would like to know where I went wrong. I have attached my working data set.
@Prest wrote:Hello again. I want to run a logistic regression. My dependent variable is Mets and independent variable is Q (Quartiles of Dietary Inflammatory Index) (coded as 1,2,3,4) My covariates are age, Energy intake,BMI, education (coded 0, 1, 2), Alcohol(0,1), exercise (0,1),smoking(o,1) and physical exercise (0,1).
proc surveylogistic data = Project1.DII_M; weight pooled_wt; cluster psu; strata kstrata; class Q (reference = '1') educn(reference='2') smoking (reference='0') exercise (reference='1') Drinking (reference='0'); model Mets (desc) = age HE_BMI educn Drinking smoking exercise N_EN Q; Domain sex; run;
I then want to calculate p for trend. To do this, I assigned the median value (Q_median) of the variable Adj_DII in each quartile category to each participant and modeled this as a continuous variable and read off the pr>t as my p for trend.
I used the following code to determine median values, assigning them to participants and running a logistic regression.
/*obtaining median in each quartile*/ proc report data=Project1.DII_Q out=dii_median; columns sex Q Adj_DII; define sex / group "Sexe"; define Q / group "Quartile"; define Adj_DII / median; run; /*Assigning median value to individuals*/ data Project1.DII_M; set Project1.DII_Q; if sex=1 and Q=1 then Q_median=-1.10; else if sex=1 and Q=2 then Q_median=0.13; else if sex=1 and Q=3 then Q_median=1.13; else if sex=1 and Q=4 then Q_median=2.27; else if sex=2 and Q=1 then Q_median=-1.22; else if sex=2 and Q=2 then Q_median=0.10; else if sex=2 and Q=3 then Q_median=1.06; else if sex=2 and Q=4 then Q_median=2.06; if HE_BMI LE 18.5 then BMI_cat=0; else if 18.5 LT HE_BMI LT 23 then BMI_cat=1; else if 23 LT HE_BMI LT 25 then BMI_cat=2; else if HE_BMI GE 25 then BMI_cat=3; Keep Age sex pooled_wt kstrata psu HE_BMI educn Drinking smoking exercise N_EN Q Mets Hy_glu Abd_obs TG_high Low_HDL HTN Q_median Adj_DII BMI_cat ; run; /*obtaining p for trend..(method adopted from some paper*/ proc surveylogistic data = Project1.DII_M; weight pooled_wt; cluster psu; strata kstrata; model Mets(desc) = age HE_BMI educn Drinking smoking exercise N_EN Q_median; Domain sex; run;
The p for trend obtained in this paper was 0.008 whereas mine is 0.09 so far from this value. I would like to know where I went wrong. I have attached my working data set.
Without seeing the paper, could be for any number of reasons. How do you expect anyone to know how your work difers from a paper when you don't provide the paper?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.