<?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 How to create a Cubic Spline Curve in survival analyse? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970634#M48768</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to create a&amp;nbsp;Cubic Spline Curve with a continuous variable on the x-axis and hazard ratio for the time to event variable on y-axis with 95% CI, I was trying to use proc phreg using the effect statement,&amp;nbsp;but not sure about the code, could you please help me to do that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jul 2025 00:10:37 GMT</pubDate>
    <dc:creator>bhr-q</dc:creator>
    <dc:date>2025-07-12T00:10:37Z</dc:date>
    <item>
      <title>How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970634#M48768</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to create a&amp;nbsp;Cubic Spline Curve with a continuous variable on the x-axis and hazard ratio for the time to event variable on y-axis with 95% CI, I was trying to use proc phreg using the effect statement,&amp;nbsp;but not sure about the code, could you please help me to do that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jul 2025 00:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970634#M48768</guid>
      <dc:creator>bhr-q</dc:creator>
      <dc:date>2025-07-12T00:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970638#M48769</link>
      <description>You could use EFFECT statement of PROC PHREG to get job done.&lt;BR /&gt;Check Rick blogs:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/06/03/vize-multivar-regression-splines.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2024/06/03/vize-multivar-regression-splines.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/02/18/regression-restricted-cubic-splines-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2019/02/18/regression-restricted-cubic-splines-sas.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/04/19/restricted-cubic-splines-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/04/19/restricted-cubic-splines-sas.html&lt;/A&gt;</description>
      <pubDate>Sat, 12 Jul 2025 05:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970638#M48769</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-07-12T05:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970653#M48770</link>
      <description>&lt;P&gt;Thank you so much for your answer. I did try the following way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc phreg data=tmp;
effect spl = spline(ind_var  / knotmethod=percentilelist(5));
model time_to_hfhosp * event(0) = spl;
store out=PhregStore;
run;
proc plm restore=PhregStore;
score data=tmp   out=SplPlot / ilink ; 
run;
proc sgplot data=SplPlot;
band x=ind_var     lower=lower_ci upper=upper_ci / transparency=0.5;
series x=ind_var   y=Predicted / lineattrs=(color=blue thickness=2);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, for the last part of the code, the log shows the following message:&lt;/P&gt;
&lt;P&gt;"ERROR: Variable &lt;CODE class=" language-sas"&gt;lower_ci&lt;/CODE&gt; not found.&lt;BR /&gt;ERROR: Variable &lt;CODE class=" language-sas"&gt;upper_ci&lt;/CODE&gt; not found."&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I fixed it as shown below and got the following plot. but, I’m not sure if it’s a correct way, as I couldn’t find any sample code that uses the &lt;CODE data-start="239" data-end="247"&gt;EFFECT&lt;/CODE&gt; statement within &lt;CODE data-start="265" data-end="277"&gt;PROC PHREG?&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc phreg data=tmp;
effect spl = spline(ind_var/ naturalcubic knotmethod=percentiles(5));
model time_to_hfhosp * event(0) = spl;
store out=PhregStore;
run;
data ScoreIn;
do ind_var = 20 to 100 by 1;   output;   end;
run;
proc plm restore=PhregStore;
score data=ScoreIn out=pred_values predicted=log_hazard stderr=se_log_hazard;
run;
data plot;
set pred_values;
hazard_ratio = exp(log_hazard);
lower_ci = exp(log_hazard - 1.96 * se_log_hazard);
upper_ci = exp(log_hazard + 1.96 * se_log_hazard);
run;
proc sgplot data=plot;
band x=ind_var lower=lower_ci upper=upper_ci / transparency=0.5;
series x=ind_var y=hazard_ratio;
refline 1 / axis=y lineattrs=(pattern=shortdash);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bhrq_0-1752362322367.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108313iFA14D6EC42D5F7D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bhrq_0-1752362322367.png" alt="bhrq_0-1752362322367.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jul 2025 23:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970653#M48770</guid>
      <dc:creator>bhr-q</dc:creator>
      <dc:date>2025-07-12T23:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970656#M48771</link>
      <description>&lt;P&gt;I think you should use HazzardRatio statement to calculate it .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bmt;
 set sashelp.bmt;
 call streaminit(123);
 ind_var=ceil(rand('normal',50,10));
run;

ods output  HazardRatios=HazardRatios;
proc phreg data=bmt;
effect spl = spline(ind_var/ degree=3);
model T * Status(0) = spl;
hazardratio 'Effect of 1-unit change in ind_var' ind_var / at(ind_var=(40 to 60 by 1));
run;

data HazardRatios2;
 set HazardRatios;
 ind_var=input(scan(Description,-1,'='),best.);
run;

proc sgplot data=HazardRatios2;
band x=ind_var lower=WaldLower upper=WaldUpper / transparency=0.5;
series x=ind_var y=HazardRatio;
refline 1 / axis=y lineattrs=(pattern=shortdash);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1752375497915.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108314iE0B7669231956984/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1752375497915.png" alt="Ksharp_0-1752375497915.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Jul 2025 02:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970656#M48771</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-07-13T02:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970676#M48772</link>
      <description>&lt;P&gt;Thank you for your answer. I think for a cubic spline curve, the Y-axis should show the predicted HR across the range of the independent variable, not the raw HR, and your way shows&amp;nbsp;the raw HR for a 1% increase in the independent variable at each level.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was thinking of using &lt;CODE data-start="571" data-end="581"&gt;PROC PLM&lt;/CODE&gt;, but not sure about my code.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Jul 2025 21:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970676#M48772</guid>
      <dc:creator>bhr-q</dc:creator>
      <dc:date>2025-07-13T21:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970679#M48773</link>
      <description>I think it is hard to use PROC PLM to get HazzardRatio, that why the reason sas showed in LOG:&lt;BR /&gt;NOTE: Hazard ratios that cannot be conveniently calculated or displayed are set to missing in the ParameterEstimates table. Use the HAZARDRATIO&lt;BR /&gt;      statement to compute the needed hazard ratios.&lt;BR /&gt;&lt;BR /&gt;Anyway, you could check LCLM UCLM option of PROC PLM:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/02/11/proc-plm-regression-models-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2019/02/11/proc-plm-regression-models-sas.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And I don't understand where is different from predicted HR and raw HR. If the ind_var value does not exist in raw data,that would lead to predicted HR,right?&lt;BR /&gt;Or maybe other stat expert would answer your question ?&lt;BR /&gt;Like: &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13758"&gt;@lvm&lt;/a&gt;  .....&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jul 2025 00:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/970679#M48773</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-07-14T00:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/971040#M48781</link>
      <description>&lt;P&gt;Thank you for your answer. I meant there is a difference between HR and predicted HR, and I was thinking the spline curve might include the predicted HR on the y-axis rather than HR. I have one independent variable in the model, named RV.&lt;/P&gt;
&lt;P&gt;I also checked the LCLM and UCLM options of PROC PLM, and I could run the code below:&lt;/P&gt;
&lt;P&gt;But the below plot is a bit strange&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc phreg data=tmp;
effect spl = spline(RV / knotmethod=percentilelist(5));
model time_to_hfhosp * event(0) = spl;
store out=PhregStore;  
run;
proc plm restore=PhregStore;
score   data=tmp out=NewScore   predicted LCLM UCLM / ilink; 
run;
proc sgplot data=NewScore  noautolegend;
band x=RV lower=LCLM upper=UCLM / transparency=0.5;
series x=RV y=Predicted / lineattrs=(color=blue thickness=2);
refline 1 / axis=y lineattrs=(pattern=shortdash color=gray);  
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bhrq_1-1752776906713.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108434i1E3162B22D71C610/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bhrq_1-1752776906713.png" alt="bhrq_1-1752776906713.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 18:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/971040#M48781</guid>
      <dc:creator>bhr-q</dc:creator>
      <dc:date>2025-07-17T18:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Cubic Spline Curve in survival analyse?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/971064#M48782</link>
      <description>"But the below plot is a bit strange"&lt;BR /&gt;Yes. That is the reason why I suggest to use HAZARDRATIO to calcuated it. HR is not easy to obtain.&lt;BR /&gt;About your other question,I have no idea about it. Maybe other sas user could help you.</description>
      <pubDate>Fri, 18 Jul 2025 00:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-create-a-Cubic-Spline-Curve-in-survival-analyse/m-p/971064#M48782</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-07-18T00:52:30Z</dc:date>
    </item>
  </channel>
</rss>

