<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I plot the spline effect of a cox model by sex? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-plot-the-spline-effect-of-a-cox-model-by-sex/m-p/710358#M34384</link>
    <description>&lt;P&gt;Moved to &lt;EM&gt;Statistics&lt;/EM&gt; community.&lt;/P&gt;</description>
    <pubDate>Sat, 09 Jan 2021 08:31:07 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-01-09T08:31:07Z</dc:date>
    <item>
      <title>How do I plot the spline effect of a cox model by sex?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-plot-the-spline-effect-of-a-cox-model-by-sex/m-p/707971#M34383</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to create a plot of the hazard ratio vs. continuous exposure by sex.&lt;/P&gt;&lt;P&gt;I used code from LinusS (&lt;A href="https://communities.sas.com/t5/SAS-Health-and-Science/How-do-I-plot-the-spline-effect-in-PHREG/m-p/626357#M2294" target="_blank"&gt;https://communities.sas.com/t5/SAS-Health-and-Science/How-do-I-plot-the-spline-effect-in-PHREG/m-p/626357#M2294&lt;/A&gt;) 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).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main change I made to LinusS's code (and the part that doesn't work) is:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; estimate "&amp;amp;value. male" sex 0 bmis [-1, &amp;amp;ref] [1, &amp;amp;value] / exp cl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; estimate "&amp;amp;value. female" sex 1 bmis [-1, &amp;amp;ref] [1, &amp;amp;value] / exp cl;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it's not working to produce sex-specific HRs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;*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( ( &amp;amp;End - &amp;amp;Start ) / &amp;amp;By ) ) ) +1) ;
      %Let value=%SysEvalF( ( &amp;amp;Start - &amp;amp;By ) + ( &amp;amp;By * &amp;amp;I ) ) ;
         estimate "&amp;amp;value. male" sex 0 bmis [-1, &amp;amp;ref] [1, &amp;amp;value] / exp cl;
         estimate "&amp;amp;value. female" sex 1 bmis [-1, &amp;amp;ref] [1, &amp;amp;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;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Dec 2020 20:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-plot-the-spline-effect-of-a-cox-model-by-sex/m-p/707971#M34383</guid>
      <dc:creator>sseb</dc:creator>
      <dc:date>2020-12-23T20:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I plot the spline effect of a cox model by sex?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-plot-the-spline-effect-of-a-cox-model-by-sex/m-p/710358#M34384</link>
      <description>&lt;P&gt;Moved to &lt;EM&gt;Statistics&lt;/EM&gt; community.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2021 08:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-plot-the-spline-effect-of-a-cox-model-by-sex/m-p/710358#M34384</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-01-09T08:31:07Z</dc:date>
    </item>
  </channel>
</rss>

