Hi, I am attempting to create a plot of the hazard ratio vs. continuous exposure by sex. I used code from LinusS (https://communities.sas.com/t5/SAS-Health-and-Science/How-do-I-plot-the-spline-effect-in-PHREG/m-p/626357#M2294) but don't know how to modify the estimate command to add sex-stratified results. Below is my code (for this example I just took LinusS's code and modified it a bit to add the parts I'm confused about). The main change I made to LinusS's code (and the part that doesn't work) is: estimate "&value. male" sex 0 bmis [-1, &ref] [1, &value] / exp cl; estimate "&value. female" sex 1 bmis [-1, &ref] [1, &value] / exp cl; But it's not working to produce sex-specific HRs. Any help is greatly appreciated! Sebastian *running the model and outputting results;
proc phreg data=temp;
effect bmiS = spline(bmi / basis=tpf(noint) NATURALCUBIC details knotmethod=list(18.0175 20.5289 22.4059 27.4693) );
class sex (ref='F') / param=ref;
model time*event(0) = bmiS|sex / rl=wald ties=EFRON ;
store sasuser.coxr;
run;
*creating macro to estimate HR at each BMI value compared to reference at BMI=20, separately for males and females;
%macro est(ref=20, start=15, end=35, by=0.1);
%Do i = 1 %To %eval(%SysFunc( Ceil( %SysEvalF( ( &End - &Start ) / &By ) ) ) +1) ;
%Let value=%SysEvalF( ( &Start - &By ) + ( &By * &I ) ) ;
estimate "&value. male" sex 0 bmis [-1, &ref] [1, &value] / exp cl;
estimate "&value. female" sex 1 bmis [-1, &ref] [1, &value] / exp cl;
%end;
%mend est;
*using the macro and outputting the results;
ods html select none;
ods rtf select none;
ods dataset Estimates=Estimates;
proc plm restore=sasuser.coxr;
%est(ref=20, start=16, end=35, by=0.01);
run;
ods html select all;
ods rtf select all;
*making some changes to output to use in sgpanel;
data estimates;
set estimates;
BMI=substr(label, 1, 2)*1;
sex=substr(reverse(label), 1, 1);
run;
proc sort data=estimates;
by sex;
run;
*producing plots;
proc sgpanel data=estimates NOAUTOLEGEND;
panelby sex;
refline 1;
Series y=ExpEstimate x=BMI;
Series y=LowerExp x=BMI;
Series y=UpperExp x=BMI;
run;
... View more