<?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 Matching CPI Values to Years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326778#M72839</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set (A) that included the year someone takes out a loan and a data set (B) that includes Consumer Price Index values by year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to check the&amp;nbsp;year in data set A and match it with a corresponding CPI value from data set B so that I can&amp;nbsp;account for inflation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this can be done with a merge or if a merge is the most efficient way to proceed. Can anyone advise?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;William&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 16:54:42 GMT</pubDate>
    <dc:creator>wrshif</dc:creator>
    <dc:date>2017-01-23T16:54:42Z</dc:date>
    <item>
      <title>Matching CPI Values to Years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326778#M72839</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set (A) that included the year someone takes out a loan and a data set (B) that includes Consumer Price Index values by year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to check the&amp;nbsp;year in data set A and match it with a corresponding CPI value from data set B so that I can&amp;nbsp;account for inflation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this can be done with a merge or if a merge is the most efficient way to proceed. Can anyone advise?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;William&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 16:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326778#M72839</guid>
      <dc:creator>wrshif</dc:creator>
      <dc:date>2017-01-23T16:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CPI Values to Years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326780#M72841</link>
      <description>&lt;P&gt;You haven't post any test data (tables A &amp;amp; B) nor example of wanted result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use &lt;STRONG&gt;sql join&amp;nbsp;&lt;/STRONG&gt; to mergae the two tables&amp;nbsp;&lt;STRONG&gt;on a.year = b.yea&lt;/STRONG&gt;&lt;STRONG&gt;r&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326780#M72841</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-23T17:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CPI Values to Years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326784#M72843</link>
      <description>&lt;P&gt;Thanks- I should clarify.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are as many as six loans recorded for each observation in data set A, so there are potentially six unique dates for when the loan was taken out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do six merges, but I'm almost sure there is a better way to handle this. Here's what I'd like to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data set A:&lt;/P&gt;&lt;P&gt;X7804 &amp;nbsp; X7827 &amp;nbsp; X7850 &amp;nbsp; X7904 &amp;nbsp; X7927 &amp;nbsp; X7950&lt;/P&gt;&lt;P&gt;1913 &amp;nbsp; &amp;nbsp; 1913 &amp;nbsp; &amp;nbsp; 1914 &amp;nbsp; &amp;nbsp; &amp;nbsp;1915 &amp;nbsp; &amp;nbsp; 1916 &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data set B:&lt;/P&gt;&lt;P&gt;Year &amp;nbsp; &amp;nbsp; CPI&lt;/P&gt;&lt;P&gt;1913 &amp;nbsp; &amp;nbsp;9.783333333&lt;BR /&gt;1914 &amp;nbsp; &amp;nbsp;9.9&lt;BR /&gt;1915 &amp;nbsp; &amp;nbsp;10.03333333&lt;BR /&gt;1916 &amp;nbsp; &amp;nbsp;10.56666667&lt;BR /&gt;1917 &amp;nbsp; &amp;nbsp;12.35&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Data Set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X7804 &amp;nbsp; X7827 &amp;nbsp; X7850 &amp;nbsp; X7904 &amp;nbsp; X7927 &amp;nbsp; X7950 &amp;nbsp; CPI1 &amp;nbsp; &amp;nbsp;CPI2 &amp;nbsp; &amp;nbsp; &amp;nbsp;CPI3 &amp;nbsp; &amp;nbsp; &amp;nbsp;CPI4 &amp;nbsp; &amp;nbsp; &amp;nbsp;CPI5 &amp;nbsp; &amp;nbsp; &amp;nbsp;CPI6&lt;/P&gt;&lt;P&gt;1913 &amp;nbsp; &amp;nbsp; 1913 &amp;nbsp; &amp;nbsp; 1914 &amp;nbsp; &amp;nbsp; &amp;nbsp;1915 &amp;nbsp; &amp;nbsp; 1916 &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.783 &amp;nbsp; 9.783 &amp;nbsp; &amp;nbsp;9.9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.03 &amp;nbsp; &amp;nbsp; 10.57 &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326784#M72843</guid>
      <dc:creator>wrshif</dc:creator>
      <dc:date>2017-01-23T17:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CPI Values to Years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326786#M72844</link>
      <description>&lt;P&gt;1) Create a format to get the CPI of a given year:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data cntl;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set B;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start = year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;label = put(cpi, z12.7);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fmtname= 'CPI_Y';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; proc format lib=work cntlin=cntl; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set A;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; array yx&amp;nbsp;&lt;SPAN&gt;X7804 &amp;nbsp; X7827 &amp;nbsp; X7850 &amp;nbsp; X7904 &amp;nbsp; X7927 &amp;nbsp; X7950;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; array cx CPI1-CPI6;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do i=1 to 6;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cx(i) = input(put(yx(i), cpi_y.),best12.7);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; run;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326786#M72844</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-23T17:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CPI Values to Years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326814#M72852</link>
      <description>&lt;P&gt;Make an array of cpi lookup values indexed by year.&amp;nbsp; Then use it for each of your 6 loans per record:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=Y);
  array cpi_lookup {1910:2016} _temporary_;
  /* First Populate the lookup array */
  if _n_=1 then do until (end_of_cpi);
    set b end=end_of_cpi;
    cpi_lookup{year}=cpi;
  end;

  set a;

  array cpi{6}       CPI7804 CPI7827 CPI7850 CPI7904 CPI7927 CPI7950 ;
  array loanyear {6} X7804 X7827 X7850 X7904 X7927 X7950 ;
  do Y=1 to dim(loanyear);
    if loanyear{Y}^=. then cpi{Y}=cpi_lookup{loanyear{Y}};
  end;

run;

  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 19:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326814#M72852</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-01-23T19:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CPI Values to Years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326826#M72856</link>
      <description>&lt;P&gt;Thank you so much, Shmuel! This worked perfectly and led me to learn more about the cntlin= option here&amp;nbsp;&lt;A href="http://www2.sas.com/proceedings/forum2007/068-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/068-2007.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 20:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CPI-Values-to-Years/m-p/326826#M72856</guid>
      <dc:creator>wrshif</dc:creator>
      <dc:date>2017-01-23T20:06:49Z</dc:date>
    </item>
  </channel>
</rss>

