BookmarkSubscribeRSS Feed
harcluna
Calcite | Level 5

Hello,

 

I'm trying to calculate the Cox hazard ratio for survival in men versus women. I thought I had the code right, but when I run it I'm only generating an HR for women (sex=0). I thought the AT statement would give me a HR for both men and women. There are no censored data.

 

Using the same data I'm also trying to calculate (as an alternative) the Weibull HR (men vs women), Weibull hazard plot (men vs women) and a Weibull survival plot (men vs women). I found a lot of information for calculating Cox proportional hazards, but not the Weibull HR or its plots. If anyone can't point me in the right direction or help with coding, it would be much appreciated. I've attached my code and a sample of my data below. Thank you. I'm using SAS UE.

 

 

data cox;

input time censor survival sex;

datalines;

0.008213552 1 0.996666667 1
0.010951403 1 0.993333333 0
0.019164956 1 0.99 1
0.030116359 1 0.986666667 0
0.032854209 1 0.983333333 0
0.035592061 1 0.98 0
0.049281314 1 0.976666667 1
0.060232717 1 0.973333333 0
0.065708419 1 0.97 0
0.06844627 1 0.966666667 0
0.07118412 1 0.963333333 0
0.073921971 1 0.96 0
0.076659822 1 0.956666667 0
0.087611225 1 0.953333333 0
0.093086927 1 0.95 0
0.095824778 1 0.946666667 0
0.101300479 1 0.943333333 1
0.109514031 1 0.94 0
0.114989733 1 0.936666667 1
0.134154689 1 0.933333333 0
0.142368241 1 0.93 0
0.150581793 1 0.926666667 0
0.161533196 1 0.923333333 0
0.169746749 1 0.92 1
0.17248461 1 0.916666667 1
0.191649555 1 0.913333333 0
0.210814511 1 0.91 0
0.227241615 1 0.906666667 1
0.235455168 1 0.903333333 0
0.246406571 1 0.9 0
0.271047228 1 0.896666667 0
0.27926078 1 0.893333333 1
0.287474333 1 0.89 1
0.323066393 1 0.886666667 1
0.331279945 1 0.883333333 0
0.334017796 1 0.88 0
0.388774812 1 0.876666667 0
;

run;

proc phreg data=cox plots(overlay)=(survival);
class sex;
model time*censor(0)=sex ;
baseline covariates=cox / rowid=sex;
hazardratio sex/at(sex=all) ;
run;

 

1 REPLY 1
pau13rown
Lapis Lazuli | Level 10

sas will output a single hazards ratio because, as you indicated, it is men versus women. To have a hazards ratio you must have a reference category. In this case it is women. You can change this in the class statement as follows: class sex (ref='Male'). In general if you have N categories then you'll have N-1 hazards ratios which all relate to the reference category. The expression 'weibull hazards ratio' doesn't really make sense. You may want to look at proc lifereg and an accelerated failure time model: http://support.sas.com/documentation/cdl/en/statug/67523/HTML/default/viewer.htm#statug_introsurv_se.... Hope this helps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 1500 views
  • 2 likes
  • 2 in conversation