<?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: merging dataset with the nearest earlier date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321971#M271047</link>
    <description>&lt;P&gt;hi astounding, sorry but would u mind helping me once more?&lt;/P&gt;
&lt;P&gt;for some reason, i am not getting the value 2. rather i am getting 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thx much&lt;/P&gt;</description>
    <pubDate>Mon, 02 Jan 2017 17:28:28 GMT</pubDate>
    <dc:creator>aarony</dc:creator>
    <dc:date>2017-01-02T17:28:28Z</dc:date>
    <item>
      <title>merging dataset with the nearest earlier date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321959#M271044</link>
      <description>&lt;P&gt;i have a dataset.&lt;/P&gt;
&lt;P&gt;ticker date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;value&lt;/P&gt;
&lt;P&gt;a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19991231 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20011231 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20031231 &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have another dataset&lt;/P&gt;
&lt;P&gt;ticker date&lt;/P&gt;
&lt;P&gt;a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20030101&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to find the nearest earlier date from the first dataset and arrive at the following:&lt;/P&gt;
&lt;P&gt;ticker date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;20030101 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;could you provide me of your guidance? thx in advance.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2017 16:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321959#M271044</guid>
      <dc:creator>aarony</dc:creator>
      <dc:date>2017-01-02T16:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: merging dataset with the nearest earlier date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321963#M271045</link>
      <description>&lt;P&gt;I'm sure SQL can handle this if you are more inclined in that direction. &amp;nbsp;But a DATA step can do it as well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want (drop=value rename=(latest_value=value));&lt;/P&gt;
&lt;P&gt;set a_dataset (in=in1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;another_dataset (in=in2);&lt;/P&gt;
&lt;P&gt;by ticker date;&lt;/P&gt;
&lt;P&gt;if first.ticker then latest_value=.;&lt;/P&gt;
&lt;P&gt;if in1 then latest_value=value;&lt;/P&gt;
&lt;P&gt;retain latest_value;&lt;/P&gt;
&lt;P&gt;if in2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2017 16:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321963#M271045</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-02T16:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: merging dataset with the nearest earlier date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321965#M271046</link>
      <description>&lt;P&gt;dear astounding. thx so much! for ur kind help!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2017 16:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321965#M271046</guid>
      <dc:creator>aarony</dc:creator>
      <dc:date>2017-01-02T16:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: merging dataset with the nearest earlier date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321971#M271047</link>
      <description>&lt;P&gt;hi astounding, sorry but would u mind helping me once more?&lt;/P&gt;
&lt;P&gt;for some reason, i am not getting the value 2. rather i am getting 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thx much&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2017 17:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/321971#M271047</guid>
      <dc:creator>aarony</dc:creator>
      <dc:date>2017-01-02T17:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: merging dataset with the nearest earlier date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/322023#M271048</link>
      <description>&lt;P&gt;Check that your data sets are mentioned in the proper order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set a_dataset (in=in1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;another_dataset (in=in2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first data set should be the one with multiple records per ticker.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's not the issue, I would need to see a few lines of data that are causing the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, if both data sets contain the same date value, this program selects the matching date (not an earlier date). &amp;nbsp;That can be changed if necessary.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2017 23:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-dataset-with-the-nearest-earlier-date/m-p/322023#M271048</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-02T23:28:34Z</dc:date>
    </item>
  </channel>
</rss>

