BookmarkSubscribeRSS Feed
unnati
Obsidian | Level 7

Base on following question i would like to know the  PROC Logistic code i wrote is correct or not. I am confuse in what variable should be in model statement. is should be age_hi or hgl_hi? and unit statement required or not.

 

Question:

I am interested in studying the association between HDL_HI (Y-variable) and AGE_HI (X-variable).

For this problem, examine whether GENDER modifies the association between HDL_HI and AGE_HI. In

other words, you need to test the interaction between AGE HI and GENDER. If there is an interaction

between AGE HI and GENDER.

age_hi --> values are 1 or 0

hgl_hi --> values are 1 or 0

As per my understanding i have write following code is it right or not:

 

ODS graphics on;

PROC LOGISTIC data=chol plots(only)=effect(x=hdl_hi) sliceby=gender)

oddsratio (type=horizontalstat));

class gender (param=ref ref='male');

model age_hi(event='1')= hdl_hi gender hdl_hi*gender;
/*unit - what should unit will be */
oddsratio 'hdl_hi 1 vs 0 for male' hdl_hi/at(gender='male' hdl_hi=1) cl=pl;

oddsratio 'hdl_hi 1 vs 0 for female' hdl_hi/at(gender='female' hdl_hi=1) cl=pl;

run;

ODS graphics off;

 

7 REPLIES 7
PaigeMiller
Diamond | Level 26

@unnati wrote:

Question:

I am interested in studying the association between HDL_HI (Y-variable) and AGE_HI (X-variable).


I think you have x and y reversed (at least according to your description) and age_hi and gender should both be class.

 

class gender (param=ref ref='male') age_hi;
model hdl_hi(event='1')= age_hi gender age_hi*gender;

 

--
Paige Miller
SteveDenham
Jade | Level 19

Regarding the 'unit' question--it enables you to calculate the odds ratio for a change of k units in the continuous variable.  Suppose k were 10 (rather than 1) for this example.  The first odds ratio statement would give you the odds ratio in males for age, if you increased hdl by 10 units.  Since @PaigeMiller  has pointed out that you likely have your X and Y variables switched, you might want to consider this:

DS graphics on;

PROC LOGISTIC data=chol plots(only)=effect(x=hdl_hi) sliceby=gender)

oddsratio (type=horizontalstat));

class gender (param=ref ref='male') age_hi(ref='1');

model hdl_hi(event='1')= age_hi gender age_hi*gender;
/*unit - what should unit will be, now since age_hi is categorical you don't need unit or the at= option */
/* I suggest going around oddsratio to SLICE with an oddsratio option 
oddsratio 'hdl_hi 1 vs 0 for male' hdl_hi/at(gender='male' hdl_hi=1) cl=pl;

oddsratio 'hdl_hi 1 vs 0 for female' hdl_hi/at(gender='female' hdl_hi=1) cl=pl;
*/
slice age_hi*gender/sliceby= genderdiff oddsratio cl;
run;

ODS graphics off;

 

 I hope this helps.

 

SteveDenham

unnati
Obsidian | Level 7
Quick question. How did you find out from the question that age_hi is categorical variable. i thought that age_hi will be numeric.
PaigeMiller
Diamond | Level 26

@unnati wrote:
Quick question. How did you find out from the question that age_hi is categorical variable. i thought that age_hi will be numeric.

This is what you stated in your original message. Yes, I agree that age should be numeric, but that's not what you said.

--
Paige Miller
SteveDenham
Jade | Level 19

Bravo, @PaigeMiller .  I was going to paste this: age_hi --> values are 1 or 0 from the OP.

 

SteveDenham

unnati
Obsidian | Level 7

As per your suggestion i update proc logistic code as below. I have added oddsratio statement because as per slice statement i wasn't getting oddsratio. By running this i getting attached output. Can you please help to interpret this output. I want to know if there is interaction between age_hi and gender from the output with explanation. how you did you interpret it.  

ods graphics on;

proc logistic data=chol_new plots(only)=(effect (x=(age_hi) sliceby=gender) 
		oddsratio (type=horizontalstat));
	class gender (param=ref ref="female") age_hi(ref='1');
	model hdl_hi(event='1')= age_hi gender age_hi*gender;
/*     unit age_hi=10;  */
/* 	oddsratio 'age_hi 10 vs 20 for male' age_hi/ cl=pl; */
/* 	oddsratio 'age_hi 10 vs 20 for female' age_hi/ cl=pl; */
	oddsratio 'age_hi for male' age_hi/at(gender='male' ) cl=pl;
	oddsratio 'age_hi for female' age_hi/at(gender='female' ) cl=pl;

slice age_hi*gender/sliceby(gender='female') diff oddsratio cl;
run;

ods graphics off;
SteveDenham
Jade | Level 19

First, to make the slice statement work, try:

 

 

slice age_hi*gender/sliceby=gender diff oddsratio cl;

 

I believe you cannot specify a reference level in the sliceby option.

 

But you have an interaction - the OR for males is significantly different from that for females.  The interpretation is pretty straightforward, the older group of males had a greater incidence of high LDL than the younger group, and exactly the opposite for the females.

 

SteveDenham

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

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.

Discussion stats
  • 7 replies
  • 1446 views
  • 3 likes
  • 3 in conversation