<?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: if Last.date then output - Returning blank results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209519#M38875</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you wanted this:&lt;/P&gt;&lt;P&gt;proc sort data=Dates;&lt;/P&gt;&lt;P&gt;by FileNo createdate;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Dates_1;&lt;/P&gt;&lt;P&gt;set Dates;&lt;/P&gt;&lt;P&gt;by FileNo;&lt;/P&gt;&lt;P&gt;if last.FileNo;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which will give you the latest createdate for any FileNo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you take a look at the log of your first try, you will get a clue where your problem is:&lt;/P&gt;&lt;P&gt;NOTE: Variable 'last.createdate'n is uninitialized.&lt;/P&gt;&lt;P&gt;A first. and last. pseudovariable is created only for those columns named in a by statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 May 2015 12:34:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2015-05-05T12:34:54Z</dc:date>
    <item>
      <title>if Last.date then output - Returning blank results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209515#M38871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to run the following code to keep only the last 'CreateDate' for each 'FileNo' however it is returning a blank dataset with the headers only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;date Dates_1;&lt;/P&gt;&lt;P&gt;set Dates;&lt;/P&gt;&lt;P&gt;If Last.createdate then output;&lt;/P&gt;&lt;P&gt;by FileNo;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assistance would be appreciated??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 11:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209515#M38871</guid>
      <dc:creator>KMW156</dc:creator>
      <dc:date>2015-05-05T11:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: if Last.date then output - Returning blank results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209516#M38872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;without the by statement first. or last. will not work, simple fix:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;date Dates_1;&lt;/P&gt;&lt;P&gt;set Dates;&lt;/P&gt;&lt;P&gt;by createdate; /*add this line, must be sorted by createdate*/&lt;/P&gt;&lt;P&gt;If Last.createdate then output;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 12:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209516#M38872</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-05-05T12:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: if Last.date then output - Returning blank results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209517#M38873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will try this now.&lt;/P&gt;&lt;P&gt;I assumed i would have to have it sorted by FileNo as i wanted to keep the last CreateDate for each FileNo.&lt;BR /&gt;I will post the outcome, although i am sure it will now work if it was a simple error as advised.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 12:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209517#M38873</guid>
      <dc:creator>KMW156</dc:creator>
      <dc:date>2015-05-05T12:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: if Last.date then output - Returning blank results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209518#M38874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, yes, I think you are trying to get the last file date for each file yes?&amp;nbsp; Mark Johnson has provided the answer, however that will just give one record for the data.&amp;nbsp; First you want to sort your data by fileno and create date, then:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;date Dates_1;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set Dates;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;by fileno createdate;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If Last.fileno then output;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Run;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;This will give one row per file with the last create date.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;You can do it in one step in SQL;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILENO,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATEDATE&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by FILENO&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having CREATEDATE=max(CREATEDATE);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 12:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209518#M38874</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-05T12:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: if Last.date then output - Returning blank results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209519#M38875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you wanted this:&lt;/P&gt;&lt;P&gt;proc sort data=Dates;&lt;/P&gt;&lt;P&gt;by FileNo createdate;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Dates_1;&lt;/P&gt;&lt;P&gt;set Dates;&lt;/P&gt;&lt;P&gt;by FileNo;&lt;/P&gt;&lt;P&gt;if last.FileNo;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which will give you the latest createdate for any FileNo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you take a look at the log of your first try, you will get a clue where your problem is:&lt;/P&gt;&lt;P&gt;NOTE: Variable 'last.createdate'n is uninitialized.&lt;/P&gt;&lt;P&gt;A first. and last. pseudovariable is created only for those columns named in a by statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 12:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-Last-date-then-output-Returning-blank-results/m-p/209519#M38875</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-05-05T12:34:54Z</dc:date>
    </item>
  </channel>
</rss>

