<?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: Linear Interpolation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465201#M118643</link>
    <description>&lt;P&gt;BY variable isn't restricted to one variable. Add all the data at once and then run the regressions with the two variables at once, which is 500*50=25,000 regressions, but whatever, the computer handles it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/183-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/183-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you could write a macro to loop it 50 times. Both approaches are covered in the paper above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 May 2018 19:37:25 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-05-25T19:37:25Z</dc:date>
    <item>
      <title>Linear Interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465194#M118636</link>
      <description>&lt;P&gt;I have 500 columns of values that I need to linear interpolate with 50 different sets of 20,000 random draws. Are there any quick ways to do this? What I have below, shows mini-examples of both of the tables I have. Then it linear interpolates all 500 columns of values over only 1 set of random draws. I need to know a quick way of doing it over all 50 (give or take) sets of random draws.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*500 (could be more/less) sets of values and their associated percentile*/
DATA Values;
INFILE DATALINES DELIMITER='|';
INPUT Percentile COL1 COL2 COL500;
DATALINES;
0.1|-100||-75|250
0.3|-20|-40|175
0.5|0|0|0
0.7|60|25|-140
0.9|150|60|-300
;RUN;

/*50 (could be more/less) sets of 20,000 (fixed) random draws*/
DATA RandomDraws;
INFILE DATALINES DELIMITER='|';
INPUT Scenario Percent1 Percent2 Percent50;
DATALINES;
1|0.06|0.54|0.22
2|0.74|0.85|0.11
3|0.98|0.08|0.41
4|0.24|0.86|0.52
20000|0.05|0.56|0.69
;RUN;

/*Stack only the first set of random draws with all 500 sets of values*/
DATA Stacked;
SET Values
 RandomDraws (RENAME=(Percent1=Percentile) DROP=Percent2--Percent50 Scenario);
RUN;

/*Linear interpolate for the first set of random draws only -- but for all 500 sets of values*/
PROC TRANSREG DATA=Stacked;
MODEL IDENTITY(COL:) = SPLINE(Percentile / DEGREE=1 NKNOTS=3);
OUTPUT
OUT=Random_Set_1
PREDICTED;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 19:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465194#M118636</guid>
      <dc:creator>SASaholic629</dc:creator>
      <dc:date>2018-05-25T19:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Linear Interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465199#M118641</link>
      <description>&lt;P&gt;I'm not exactly following, but I would suggest transposing your data so you're dealing with a long format instead and then use a BY statement in the PROC TRANSREG to have the regression done by each draw/variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;similar to the concept here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regressions/ta-p/223663" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regressions/ta-p/223663&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I'm misinterpreting your question, feel free to disregard this message.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 19:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465199#M118641</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-25T19:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Linear Interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465200#M118642</link>
      <description>&lt;P&gt;I thought about that (used that exact method last week for something else). The BY statement would do it for each of my 500 sets of values over only 1 of my sets of random draws. The BY statement would allow it to work for all 500 at once. Which is good, but not good enough. I need it to do all 500, 50 different times, all at once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: Give me a few minutes and I'll post exactly what I have above using the BY statement so you can see it still gets me to the same place.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 19:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465200#M118642</guid>
      <dc:creator>SASaholic629</dc:creator>
      <dc:date>2018-05-25T19:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Linear Interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465201#M118643</link>
      <description>&lt;P&gt;BY variable isn't restricted to one variable. Add all the data at once and then run the regressions with the two variables at once, which is 500*50=25,000 regressions, but whatever, the computer handles it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/183-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/183-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you could write a macro to loop it 50 times. Both approaches are covered in the paper above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 19:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465201#M118643</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-25T19:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Linear Interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465210#M118649</link>
      <description>&lt;P&gt;I didn't realize this could work for more than one variable - thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 20:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-Interpolation/m-p/465210#M118649</guid>
      <dc:creator>SASaholic629</dc:creator>
      <dc:date>2018-05-25T20:00:37Z</dc:date>
    </item>
  </channel>
</rss>

