<?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/225545#M40504</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6107"&gt;@mspak&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with the inherent ratio for years 1971, 1980, 1990, 2000 and 2010. I would like to interpolate the between values (for example, 1972 - 1979, 1981 - 1989, 1991 - 1999, 2001 - 2009, and 2011 - 2014) in my data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone suggest a good solution for the linear interpolation?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Linear interpolation can be performed in a SAS data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;interp=(y1-y0)*(year-prevyear)/(nextyear-prevyear);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where y1 is the inherent ratio of the next known year (1971, 1980, 1990, 2000 and 2010), y0 is the inherent ratio of the previous known year (1971, 1980, 1990, 2000 and 2010), and prevyear is the previous known year, and nextyear is the next known year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Linear interpolation, with this data, will not work for 2011-2014.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Sep 2015 12:05:58 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2015-09-15T12:05:58Z</dc:date>
    <item>
      <title>Linear interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225521#M40496</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with the inherent ratio for years 1971, 1980, 1990, 2000 and 2010. I would like to interpolate the between values (for example, 1972 - 1979, 1981 - 1989, 1991 - 1999, 2001 - 2009, and 2011 - 2014) in my data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone suggest a good solution for the linear interpolation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MSPAK&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 07:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225521#M40496</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2015-09-15T07:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Linear interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225545#M40504</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6107"&gt;@mspak&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with the inherent ratio for years 1971, 1980, 1990, 2000 and 2010. I would like to interpolate the between values (for example, 1972 - 1979, 1981 - 1989, 1991 - 1999, 2001 - 2009, and 2011 - 2014) in my data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone suggest a good solution for the linear interpolation?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Linear interpolation can be performed in a SAS data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;interp=(y1-y0)*(year-prevyear)/(nextyear-prevyear);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where y1 is the inherent ratio of the next known year (1971, 1980, 1990, 2000 and 2010), y0 is the inherent ratio of the previous known year (1971, 1980, 1990, 2000 and 2010), and prevyear is the previous known year, and nextyear is the next known year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Linear interpolation, with this data, will not work for 2011-2014.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 12:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225545#M40504</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-09-15T12:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Linear interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225570#M40510</link>
      <description>&lt;P&gt;I think you can also do linear interpolation in PROC TRANSREG where your KNOTS are the years 1971, 1980, 1990, 2000 and 2010, and the degree of the spline fit is 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUT ... CAUTION ... I have never actually done this.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 13:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225570#M40510</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-09-15T13:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Linear interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225682#M40531</link>
      <description>&lt;P&gt;So, I have peaked my own curiosity about doing this in PROC TRANSREG, and so here is a simple example, where I have averaged all of the data by FYEAR just to keep things simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary nway data=one_two;
    class fyear;
    var inherent;
    output out=means mean=;
run;
data augment;
    do fyear=1971 to 2010 by 1;
        output;
    end;
run;
data means;
    set means augment;
run;
proc transreg data=means(drop=_type_ _freq_);
    model identity(inherent)=spline(fyear/knots=1971 1980 1990 2000 2010 degree=1);
    output out=interpolation predicted residual;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Sep 2015 18:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/225682#M40531</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-09-15T18:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Linear interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/226038#M40644</link>
      <description>&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with county-based and state-based adherent levels.&amp;nbsp; I tried to modify your program for my purpose. But I find somethign wrong the output. I would like to seek for your further advise. The following is the modified program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc summary nway data=z.adherent;&lt;BR /&gt;class fips fyear;&lt;BR /&gt;var adherent_county;&lt;BR /&gt;output out=means mean=;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data augment;&lt;BR /&gt;do fyear=1990 to 2010 by 1;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=MEANS OUT=FIPS (KEEP=FIPS) NODUPKEY;&lt;BR /&gt;BY FIPS;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;create table all as&lt;BR /&gt;select *&lt;BR /&gt;from augment, fips;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data adherent;&lt;BR /&gt;set means all;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=adherent;&lt;BR /&gt;by fips fyear;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transreg data=adherent(drop=_type_ _freq_);&lt;BR /&gt;model identity(adherent_county)= spline(fyear/knots=1990 2000 2010 degree=1);&lt;BR /&gt;output out=interpolation predicted residual;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My purpose is to interpolate the adherent levels between 1990 to 2010 for each county. My next step is to perform the interpolation again for the state-based adherent level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope to get any useful information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MSPAK&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 12:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/226038#M40644</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2015-09-17T12:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Linear interpolation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/226074#M40655</link>
      <description>&lt;P&gt;If I understand you properly, you need to have a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BY FIPS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;statement in PROC TRANSREG&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 15:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Linear-interpolation/m-p/226074#M40655</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-09-17T15:32:37Z</dc:date>
    </item>
  </channel>
</rss>

