<?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: Trying to select the most recent row of data that has all dates present in a data table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462488#M117754</link>
    <description>&lt;P&gt;Please explain further. The hot pink row doesn't have all dates present.&lt;/P&gt;</description>
    <pubDate>Tue, 15 May 2018 19:32:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-05-15T19:32:26Z</dc:date>
    <item>
      <title>Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462483#M117752</link>
      <description>&lt;P&gt;I'm trying to select the most recent row of data that has all dates present within a data table.&amp;nbsp; I've tried several things without success and need to resolve this.&amp;nbsp; I'm pretty new to SAS and only know basic commands.&amp;nbsp; Here is an example of my data table,&amp;nbsp;the row of data I need is the one highlighted in 'Hot Pink'&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Any help is appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Account&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Breed&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Bill&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Ltr1_dte&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Ltr2_dte&lt;/STRONG&gt;&lt;/TD&gt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lt;/TD&gt;&lt;TD&gt;Tabby&lt;/TD&gt;&lt;TD&gt;001&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 15 May 2018 19:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462483#M117752</guid>
      <dc:creator>ScotchCat</dc:creator>
      <dc:date>2018-05-15T19:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462488#M117754</link>
      <description>&lt;P&gt;Please explain further. The hot pink row doesn't have all dates present.&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 19:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462488#M117754</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-15T19:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462490#M117756</link>
      <description>The example is how the data table is structured, the letter dates can have 'missing' values or 'holes'. That has added to this challenge, it's not a simple Max date situation.&lt;BR /&gt;</description>
      <pubDate>Tue, 15 May 2018 19:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462490#M117756</guid>
      <dc:creator>ScotchCat</dc:creator>
      <dc:date>2018-05-15T19:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462491#M117757</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210216"&gt;@ScotchCat&lt;/a&gt; wrote:&lt;BR /&gt;The example is how the data table is structured, the letter dates can have 'missing' values or 'holes'. That has added to this challenge, it's not a simple Max date situation.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you will need to provide a much clearer definition of what exactly entails "all dates present" and "most recent".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect the issue is having any record with more than one "letter date" at all. Did you reformat another data table to get this structure or did someone using a spreadsheet expect you to magically read their mind for intent?&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 19:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462491#M117757</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-15T19:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462492#M117758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210216"&gt;@ScotchCat&lt;/a&gt; wrote:&lt;BR /&gt;The example is how the data table is structured, the letter dates can have 'missing' values or 'holes'. That has added to this challenge, it's not a simple Max date situation.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, this is not an explanation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your original criterion "&lt;SPAN&gt;I'm trying to select the most recent row of data that has all dates present within a data table" is not met by the hot pink row, and your statement quoted above does not clarify what you are looking for.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 19:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462492#M117758</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-15T19:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462493#M117759</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210216"&gt;@ScotchCat&lt;/a&gt; wrote:&lt;BR /&gt;The example is how the data table is structured, the letter dates can have 'missing' values or 'holes'. That has added to this challenge, it's not a simple Max date situation.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210216"&gt;@ScotchCat&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Before going into coding one must determine the logic to be implemented. For your sample data:&lt;/P&gt;
&lt;P&gt;1. What is the definition of &lt;STRONG&gt;all dates&lt;/STRONG&gt; given that the row you've marked has missing dates?&lt;/P&gt;
&lt;P&gt;2. What constitutes &lt;STRONG&gt;most recent row &lt;/STRONG&gt;given that the non missing dates are all the same in a column?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 19:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462493#M117759</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-15T19:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462495#M117761</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
call missing(flag);
do _n_=1 by 1 until(last.account);
set have;
by account;
if n(of Ltr:)=0 and missing(flag) then   flag=_n_-1;
end;
do _n_=1 by 1 until(last.account);
set have;
by account;
if flag=_n_ then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 May 2018 19:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462495#M117761</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-15T19:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462502#M117764</link>
      <description>&lt;P&gt;My apologies if I'm not clear, I'll try to explain.&amp;nbsp; In the table example, letters have been sent out, however not all were sent, leaving some of the columns blank.&amp;nbsp; I'm looking&amp;nbsp;for the last&amp;nbsp;row of data that contains the most letter dates before the letter dates are all&amp;nbsp;blank.&amp;nbsp;&amp;nbsp;Thanks, &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 20:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462502#M117764</guid>
      <dc:creator>ScotchCat</dc:creator>
      <dc:date>2018-05-15T20:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462503#M117765</link>
      <description>&lt;P&gt;Given your subsequent description, it sounds like you need only one date present (or more, of course).&amp;nbsp; Here's a simple way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by account;&lt;/P&gt;
&lt;P&gt;where (ltr1_date &amp;gt; . or ltr2_date &amp;gt; . or ltr3_date &amp;gt; . or ltr4_date &amp;gt; . or ltr5_date &amp;gt; .);&lt;/P&gt;
&lt;P&gt;if last.account;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are other conditions required (besides the presence of at least one date), we might be able to modify the WHERE statement ... depends on what the conditions are.&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 20:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462503#M117765</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-15T20:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to select the most recent row of data that has all dates present in a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462507#M117768</link>
      <description>&lt;P&gt;Thank You So Much!!&amp;nbsp; This is working!!&amp;nbsp; I really appreciate it!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 20:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-select-the-most-recent-row-of-data-that-has-all-dates/m-p/462507#M117768</guid>
      <dc:creator>ScotchCat</dc:creator>
      <dc:date>2018-05-15T20:26:24Z</dc:date>
    </item>
  </channel>
</rss>

