<?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 Cubic Spline in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cubic-Spline/m-p/473837#M285882</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have data as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;Time = X&lt;/P&gt;&lt;P&gt;&amp;nbsp;Result = Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Time (Months)&amp;nbsp; &amp;nbsp;Result&lt;/P&gt;&lt;P&gt;0 7.17&lt;/P&gt;&lt;P&gt;3 5.98&lt;/P&gt;&lt;P&gt;6 7.31&lt;/P&gt;&lt;P&gt;12 73.87&lt;/P&gt;&lt;P&gt;18 80.92&lt;/P&gt;&lt;P&gt;30 39.11&lt;/P&gt;&lt;P&gt;36 37.93&lt;/P&gt;&lt;P&gt;42 33.3&lt;/P&gt;&lt;P&gt;48 35.2&lt;/P&gt;&lt;P&gt;78 33.26&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to fit a cubic spline to the data, and then find Y-values for 8 equal time points between 19.2 and 44.4 months. And then do a regression on those 8 data points to find a slope.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been playing around with proc glmselect, and I get 5 knots and their parameters...but I can't seem to apply the equation correctly after the first knot, I am not sure how to get SAS to show me the&amp;nbsp;other parts of the predictive equation (i.e. the second intercept)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how far I got:&lt;/P&gt;&lt;P&gt;ods select ANOVA ParameterEstimates SplineKnots TPFSplineDeatils;&lt;BR /&gt;ods output ParameterEstimates=param SplineKnots=spline ;&lt;BR /&gt;proc glmselect data=patient1;&lt;BR /&gt;effect spl = spline( time/ details naturalcubic basis=tpf(noint)&lt;BR /&gt;knotmethod=percentiles(5) );&lt;BR /&gt;model result = spl / selection=none ; /* fit model by using spline effects */&lt;BR /&gt;output out=SplineOut predicted=fit ; /* output predicted values for graphing */&lt;BR /&gt;quit;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jun 2018 17:24:09 GMT</pubDate>
    <dc:creator>darb</dc:creator>
    <dc:date>2018-06-27T17:24:09Z</dc:date>
    <item>
      <title>Cubic Spline</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cubic-Spline/m-p/473837#M285882</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have data as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;Time = X&lt;/P&gt;&lt;P&gt;&amp;nbsp;Result = Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Time (Months)&amp;nbsp; &amp;nbsp;Result&lt;/P&gt;&lt;P&gt;0 7.17&lt;/P&gt;&lt;P&gt;3 5.98&lt;/P&gt;&lt;P&gt;6 7.31&lt;/P&gt;&lt;P&gt;12 73.87&lt;/P&gt;&lt;P&gt;18 80.92&lt;/P&gt;&lt;P&gt;30 39.11&lt;/P&gt;&lt;P&gt;36 37.93&lt;/P&gt;&lt;P&gt;42 33.3&lt;/P&gt;&lt;P&gt;48 35.2&lt;/P&gt;&lt;P&gt;78 33.26&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to fit a cubic spline to the data, and then find Y-values for 8 equal time points between 19.2 and 44.4 months. And then do a regression on those 8 data points to find a slope.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been playing around with proc glmselect, and I get 5 knots and their parameters...but I can't seem to apply the equation correctly after the first knot, I am not sure how to get SAS to show me the&amp;nbsp;other parts of the predictive equation (i.e. the second intercept)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how far I got:&lt;/P&gt;&lt;P&gt;ods select ANOVA ParameterEstimates SplineKnots TPFSplineDeatils;&lt;BR /&gt;ods output ParameterEstimates=param SplineKnots=spline ;&lt;BR /&gt;proc glmselect data=patient1;&lt;BR /&gt;effect spl = spline( time/ details naturalcubic basis=tpf(noint)&lt;BR /&gt;knotmethod=percentiles(5) );&lt;BR /&gt;model result = spl / selection=none ; /* fit model by using spline effects */&lt;BR /&gt;output out=SplineOut predicted=fit ; /* output predicted values for graphing */&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 17:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cubic-Spline/m-p/473837#M285882</guid>
      <dc:creator>darb</dc:creator>
      <dc:date>2018-06-27T17:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cubic Spline</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cubic-Spline/m-p/473872#M285883</link>
      <description>&lt;P&gt;I am confused by several things you said, but it sounds like you want to score the fitted model at 8 evenly-spaced points between 19.2 and 44.4. &lt;A href="https://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html" target="_self"&gt;You can use the SCORE statement or use the STORE statement and PROC PLM&lt;/A&gt;, as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Patient1;
input Time  Result;
datalines;
0 7.17
3 5.98
6 7.31
12 73.87
18 80.92
30 39.11
36 37.93
42 33.3
48 35.2
78 33.26
;


ods select ANOVA ParameterEstimates SplineKnots TPFSplineDetails;
ods output ParameterEstimates=param SplineKnots=spline ;
proc glmselect data=patient1;
effect spl = spline( time/ details naturalcubic basis=tpf(noint)
knotmethod=percentiles(5) );
model result = spl / selection=none ; /* fit model by using spline effects */
output out=SplineOut predicted=fit ; /* output predicted values for graphing */
store out=MyModel;
quit;

data ScoreData;
startT = 19.2;
endT = 44.4;
N = 8;
dt = (endT - startT) / (N-1);
do Time = startT to endT by dt;
   output;
end;
keep Time;
run;

proc plm restore=MyModel;
   score data=ScoreData out=ScoreResults;
run;

proc sgplot data=ScoreResults; 
   series x=Time y=Predicted; /* do you want the fitted curve? */
run;

proc sgplot data=ScoreResults;
   reg x=Time y=Predicted; /* you said something about a slope? */
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is unclear is the sentence " do a regression on those 8 data points to find a slope."&amp;nbsp; Perhaps the hint above will provide the points that you need for the regression? You can use PROC REG to get the regression estimates, including the slope. If&amp;nbsp;that's not what you want,&amp;nbsp;then&amp;nbsp;please&amp;nbsp;explain further.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 18:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cubic-Spline/m-p/473872#M285883</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-06-27T18:49:16Z</dc:date>
    </item>
  </channel>
</rss>

