<?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: Write contrast between interaction between a continous and spline variable in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992180#M49523</link>
    <description>&lt;P&gt;You might also find it useful to plot the hazard ratio as a function of your two predictors as shown in the "Hazard Ratios for a Splined Variable Interacting with a Continuous Variable" section of this &lt;A href="https://sas.service-now.com/csm?id=kb_article_view&amp;amp;sysparm_article=KB0044200" target="_self"&gt;knowledge base article&lt;/A&gt;. With the plot, you can visualize the change over either predictor.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Aug 2026 15:25:55 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2026-08-18T15:25:55Z</dc:date>
    <item>
      <title>Write contrast between interaction between a continous and spline variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992157#M49519</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have two variables - spline variable of height and another continuous variable.&amp;nbsp; How do I write contrast to get difference in spline effects of height with respect to a reference at height=60 for interacting effect of weight?&amp;nbsp; I have written the code but the ESTIMATE results do not coincide with the manual calculation.&amp;nbsp; Any tip would be greatly appreciated.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;**sample data;
data mydata;
call streaminit(12345);

/* Generate 2,000 matched case-control strata (1 case, 3 controls per stratum) */
do stratum_id = 1 to 2000;
/* Assign a random Zip code AC percentage to the stratum (0% to 100%) */
ac_percent = rand("Uniform", 0.10, 0.90);

do obs = 1 to 4;
/* Temperature range: 5°C to 35°C */
temp = rand("Uniform", 5, 35);

/* First observation in stratum is the case (Y=1), others are controls (Y=0) */
if obs = 1 then Y = 1; 
else Y = 0;

output;
end;
end;
run;


proc phreg data=mydata;
strata stratum_id;
/* Define B-spline for temperature */
effect temp_bs = spline(temp / degree=3 knotmethod=equal(4));
/* Y=0 as censoring variable simulates case-control outcome */
model obs*Y(0) = temp_bs temp_bs*ac_percent / ties=discrete;
ESTIMATE 'Log-OR (Temp=5 vs 20) at AC=0.10' temp_bs [1, 5] [-1, 20] temp_bs*ac_percent [1, 0.10 5] [-1, 0.10 20];
store work.spline_model;
run;

***this does not coincide with the following code;
data grid_data;
do temp = 5 to 35 by 0.5;
do ac_percent = 0.10 to 0.90 by 0.05;
output;
end;
end;
run;

/* Set Reference Temperature T0 = 20°C */
data ref_data;
temp = 20;
/* AC percentage value here cancels out when taking differences */
ac_percent = 0;
run;

/* Score grid points */
proc plm restore=work.spline_model;
score data=grid_data out=grid_scored pred=link_grid stderr=se_grid; *pred=xbeta;
run;

/* Score reference point (T0 = 20°C) */
proc plm restore=work.spline_model;
score data=ref_data out=ref_scored pred=link_ref stderr=se_ref;; *pred=xbeta;
run;

/* Merge reference value to grid and compute Odds Ratio relative to 20°C */
data plot_data;
if _N_ = 1 then set ref_scored(keep=link_ref);
set grid_scored;
* Log Odds Ratio = Log-hazard(T) - Log-hazard(T0=20°C);
log_or = link_grid - link_ref;
or_val = exp(log_or);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2026 21:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992157#M49519</guid>
      <dc:creator>PamG</dc:creator>
      <dc:date>2026-08-17T21:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Write contrast between interaction between a continous and spline variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992164#M49520</link>
      <description>&lt;A href="https://sas.service-now.com/csm/en/assess-the-effect-of-a-continuous-variable-using-a-contrast-or-estimate?id=kb_article_view&amp;amp;sysparm_article=KB0058379" target="_blank"&gt;https://sas.service-now.com/csm/en/assess-the-effect-of-a-continuous-variable-using-a-contrast-or-estimate?id=kb_article_view&amp;amp;sysparm_article=KB0058379&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://sas.service-now.com/csm/en/examples-of-writing-contrast-and-estimate-statements?id=kb_article_view&amp;amp;sysparm_article=KB0057059" target="_blank"&gt;https://sas.service-now.com/csm/en/examples-of-writing-contrast-and-estimate-statements?id=kb_article_view&amp;amp;sysparm_article=KB0057059&lt;/A&gt;</description>
      <pubDate>Tue, 18 Aug 2026 06:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992164#M49520</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-08-18T06:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Write contrast between interaction between a continous and spline variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992176#M49521</link>
      <description>&lt;P&gt;Because the AC value is involved in the interaction, I do not think it would cancel out as your comment in the REF_DATA suggests (e.g. it should not be zero).&amp;nbsp; If you set the AC_PERCENT=.10 instead of 0 then it will match what the ESTIMATE statement is giving.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2026 13:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992176#M49521</guid>
      <dc:creator>SAS_Rob</dc:creator>
      <dc:date>2026-08-18T13:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Write contrast between interaction between a continous and spline variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992177#M49522</link>
      <description>&lt;P&gt;Thanks Ksharp.&amp;nbsp; The documents do not give exactly what I was looking for.&amp;nbsp; But I figured out what is going on.&amp;nbsp; My manual calculation is at a specific level of AC and the numbers do match.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2026 13:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992177#M49522</guid>
      <dc:creator>PamG</dc:creator>
      <dc:date>2026-08-18T13:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Write contrast between interaction between a continous and spline variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992180#M49523</link>
      <description>&lt;P&gt;You might also find it useful to plot the hazard ratio as a function of your two predictors as shown in the "Hazard Ratios for a Splined Variable Interacting with a Continuous Variable" section of this &lt;A href="https://sas.service-now.com/csm?id=kb_article_view&amp;amp;sysparm_article=KB0044200" target="_self"&gt;knowledge base article&lt;/A&gt;. With the plot, you can visualize the change over either predictor.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2026 15:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Write-contrast-between-interaction-between-a-continous-and/m-p/992180#M49523</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2026-08-18T15:25:55Z</dc:date>
    </item>
  </channel>
</rss>

