Calcite | Level 5

## Estimate hazard ratio for the treatment at specific values for age by using splines

I would like to show that the treatment effect vary depending on age, and the relationship is nonlinear.

To do so, I would like to conduct statistical analysis and plot which are described in attached article entitled "Statins for primary prevention of cardiovascular events and mortality in old and very old adults with and without type2 diabetes: retrospective cohort study".

In this study, statin is useful in younger patients with diabetes mellitus, but not in elderly patients.

In Figure 2, x-axis represents age and y-axis represents the hazard ratio for statin use.

I tried to create the SAS code for this, but it did not work.

********************************************SAS code***********************************************************

proc phreg data=DATA1;
effect SPL = spline(AGE/ degree=2 basis=tpf(noint) details knotmethod=rangefractions(0.25 0.50 0.75) );
class STATIN/param=ref;
model MACE_TIME * MACE(0)=SPL AGE AGE*SPL
/rl=wald ties=EFRON;
store splineout;
run;

%macro est(ref,start,end,by);
%Do i = 1 %To %eval(%SysFunc( Ceil( %SysEvalF( ( &End - &Start ) / &By ) ) ) +1) ;
%Let value=%SysEvalF( ( &Start - &By ) + ( &By * &I ) ) ;
estimate "&value." SPL &value STATIN [1,1] [-1,0]/ exp cl;
%end;
%mend est;

ods dataset Estimates=Estimates;
proc plm restore=splineout;
%est(ref=35, start=35, end=100, by=5);
run;

data estimates;
set estimates;
AGE=label*1;
run;

proc sgplot data=estimates ;
title "Effect of age" ;
Series y=ExpEstimate x=AGE /LINEATTRS=(THICKNESS=3 color=black) ;
Series y=LowerExp x=AGE / LINEATTRS=(pattern=ShortDash color=Black THICKNESS=1);
Series y=UpperExp x=AGE / LINEATTRS=(pattern=ShortDash color=Black THICKNESS=1);
REFLINE 1 / axis=y;
yaxis Values=(0 to 5 by 1) Label="Hazard Ratio";
xaxis min=11 VALUES=(35 to 100 by 5) Label="Age" ;
run;

********************************************SAS code***********************************************************

I am looking for a way to get an estimate for the hazard ratio for treatment at specific values for age.

Sophie post a similar question, and Steve recommended to use "lsmestimate".

However, lsmestimate statement cannot be used in PHREG procedure.

It is appreciated if you could tell me how to do this.

Enzan

7 REPLIES 7
Lapis Lazuli | Level 10

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

I'm not sure maybe this is a feature of a newer SAS/STAT Version then you have - but SAS/STAT 15.1 supports it just fine: https://documentation.sas.com/?docsetId=statug&docsetVersion=15.1&docsetTarget=statug_phreg_syntax.h...

Calcite | Level 5

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

Dear Criptic

I'm sorry, I did not clarify the problem.

Proc PHREG procedure which I described above work well.

However, I don't know how to estimate the hazard ratio for treatment use at the specific values for age

because I'm not familiar with "estimate" statement.

Enzan

SAS Super FREQ

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

Your model looks rather odd - you define STATIN as a CLASS variable but don't use it in the model. And you define a spline on AGE but then use both AGE and its spline in the model. Assuming that STATIN is your treatment variable, I assume what you want in your model is STATIN SPL*STATIN.

I think you can then use the LSMEANS statement with the AT option to do what you are looking for. See the example in this note

Calcite | Level 5

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

I'm sorry, that is wrong code.

This is the corrected SAS code.

Also I added lsmeans statement as you recommended.

**********************************************SAS code***********************************************************

proc phreg data=DATA1;
effect SPL = spline(AGE/ degree=2 basis=tpf(noint) details knotmethod=rangefractions(0.25 0.50 0.75) );
class STATIN/param=ref;
model MACE_TIME * MACE(0)=SPL STATIN STATIN*SPL
/rl=wald ties=EFRON;
store splineout;

lsmeans STATIN / at SPL=50;

run;

**********************************************SAS code***********************************************************

However, after running this SAS code, caution said

"The model does not have a GLM parameterization. This parameterization is required for the TEST, LSMEANS, LSMESTIMATE, and
SLICE statement. These statements are ignored."

I'm using SAS university edition(SAS/STAT version is 15.1).

According to this paper " https://www.pharmasug.org/proceedings/2011/SAS/PharmaSUG-2011-SAS-SP01.pdf ",

"LSMEANS" statement supports the "PHREG" procedure.

Could you please tell me how to deal with this?

SAS Super FREQ

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

Just add the PARAM=GLM option following a slash (/) at the end of the CLASS statement so that GLM parameterization is used.

Calcite | Level 5

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

I understood "param=glm" option and correct SAS code as below.

proc phreg data=DATA1;
effect SPL = spline(AGE/ degree=2 basis=tpf(noint) details knotmethod=rangefractions(0.25 0.50 0.75) );
class STATIN/param=glm;
model MACE_TIME * MACE(0)=SPL STATIN STATIN*SPL
/rl=wald ties=EFRON;
store splineout;

lsmeans STATIN "50" /at AGE=50 adjust=tukey cl exp;

lsmestimate STATIN "50" 1 -1 / at AGE=50 e cl exp;

run;

Does this "lsmeans" estimate calculate hazard ratio for statin use vs. non statin use at age of 50?

Is this correct?

The result obtained from this program was attached (lsmeans_result.tif)

Calcite | Level 5

## Re: Estimate hazard ratio for the treatment at specific values for age by using splines

Also I used "lsmestimate".

The results I obtained from this statement was also attached (lsmestimate_result).

It seems that something was wrong.

Is my SAS program correct code?

Discussion stats
• 7 replies
• 1192 views
• 0 likes
• 3 in conversation