# How to calculate Log Hazard Ratio in SAS

#### sandeep249

##### New Member
Code:
proc phreg data = analysis ;
class c diabetes /descending;
model days*ind(0) = c diabetes id/ rl ;
id= c *diabetes;
hazardratio id;
run;
I am trying to run a simple Cox Regression in SAS. I cant seem to find a way to calculate log-hazard ratio for my variables in the model. The hazard ratio statement and the /rl options gives hazard ratio with 95% CI, but I want log-hazard ratio with 95% CI limits.

#### hlsmith

##### Less is more. Stay pure. Stay poor.
I will check this out in the morning when i have access to a computer. Since you have covariates this wouldnt be "simple ". What is the "id" variable, it appears to be continuous?

#### hlsmith

##### Less is more. Stay pure. Stay poor.
See sas paper from global forum : #253-2010, for coding options.

#### hlsmith

##### Less is more. Stay pure. Stay poor.

That is, β is the logarithm of the ratio of the hazard rate for subjects

belonging to the group denoted by
X = 1 to the hazard function for subjects

belonging to the group indicated by

X = 0.

The parameter β is a log relative risk and exp(β) is a relative risk of

response; PH regression is sometimes called “relative risk regression”.

• If we conclude that the data provide reasonable evidence to contradict the

hypothesis that

X is unrelated to response, exp( ˆ β) is a point estimate of the

rate at which response occurs in the group denoted by

X = 1 relative to the

rate at which response occurs at the same time in the group denoted by

X = 0.

A confidence interval for β, given by ˆ β ・} 1.96SE, represents a range of

plausible values for the log relative risk associated with the corresponding

explanatory variable.

#### sandeep249

##### New Member
See sas paper from global forum : #253-2010, for coding options.
Thanks for your help with this. I am familiar with this paper and it does provide a very good overview of using some of the more complicated options in CLASS, CONTRAST, and HAZARDRATIO Statements.

I simply used the CONTRAST statement to calculate the log-hazard ratio with the 95% CI. There is no other easy way to do this in SAS. So one has to write out the contrast statement for every permutation and combination - and it does get complicated if you have interactions in your model.

Thanks again!

#### hlsmith

##### Less is more. Stay pure. Stay poor.
sandeep249,

Can you post your code, so to help others with this same question. You can change variable names to deidentify you research/project. And yes, the 253-2010 paper seemed very helpful in regards to some available options.

#### sandeep249

##### New Member
Here's the code for the solution. Nothing too complicated but you need to know how to correctly write the contrast statement:

Code:
proc phreg data = analysis ;
class 			cat1 (ref="yes") cat2 (ref="yes") /descending;
model 		days*ind(0) = cat1 | cat2/ rl;
hazardratio cat1 /diff=ref ;
contrast 'test this value, should be same as that from hazratio statement' cat1 1 / estimate = both;
contrast 'cat1=yes for cat2=yes' cat1 1 cat1*cat2 1 / estimate = both;
run;