SAS Proc Phreg

SAS day 17: Proc Phreg


One day, my boss took a glance at a table with Hazard Ratio and Median Survival Time then he told me the program set the reference group in Proc Phreg flipped.

It turns out he was correct after validating the program. However, I was very curious about how did he figure it out by an Augenblick. Then he shared with us some knowledge about Hazard Ratio and Proc Phreg.


Background knowledge

Hazard Rate: Hazard Rate represents instantaneous risk at the given time for patients in one treatment group.

Hazard Ratio: the ratio between two Hazard Rate.

Median Survival Time:  The time after which 50 percent of people with a particular condition are still living, and 50 percent have died.

Median survival time and Hazard Rate

if Median(A) > Median(B) then Hazard Rate(A) < Hazard Rate(B), vice versa.

Under the proportional hazards assumption, theoretically, if the median survival time of group A is significantly longer than group B, then the Hazard Rate of group A is smaller than Hazard Rate of group B at any given time, vice versa.
Note: There were rare cases, this rule does not follow


qimono / Pixabay



Now we will demonstrate Proc Phreg with Hazard Ratio with Sashelp.BMT dataset.

Basic Proc Phreg Syntax

Proc phreg data=a;
class x ; /*ref(x) only character value, the lowest character value is reference*/
model x*y= a/rl ; /*can input more than one variable on the RHS of the equation. rl:risk limit (eßt)*/
by z;/*optional*/ 
id m;/*optional*/


  1. Read in the sashelp.BMT dataset and only consider AML Low Group and AML High Group
    Note: Hazard Ratio is usually designed for two-level comparison,
    we will introduce 3-level comparison next time.
data aml;
set sashelp.bmt;
if group="AML-Low Risk" then ref="0";
if group="AML-High Risk" then ref="1";
if ref in("0","1");

2.  Apply Proc Phreg to generate the hazard ratio

proc phreg data=aml outest=est61 covout;
class ref;
model T*status(0)=ref/rl;



From the output, we have Hazard Ratio=0.39, which means the risk of death a patient in AML Low Group survives until today and will survive until tomorrow, compared with the AML High Group Reduced by 0.61, (1-HR)*100%.

Alternatively, we can say that in AML Low Group patients have a 156% (1/HR-1)*100% improvement in the chance of surviving longer than AML High Patients.


As we mentioned earlier, if Hazard Rate <1 then we expected a longer survival median time in AML Low Group. The following Kaplan Meier plot demonstrated the AML Low Group indeed has a larger survival median.

proc lifetest data=aml plots=survival;
time T*status(0);
strata Group;


Special thanks to Joe wang, not only sharing the Proc Phreg knowledge with us but also went over the Key points with me in a great level of details to make sure i truly understood the material. we will show the 3-level Hazard Ratio in Proc Phreg next time!

Happy studying! 🐰


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: