<?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: How to get max created date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519553#M73362</link>
    <description>&lt;P&gt;If you want the date portion of a variable containing datetime then the function is DATEPART(variable). You likely want to provide a date format to go along with that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something similar to&lt;/P&gt;
&lt;PRE&gt;Proc sql;
   Create table test as
   Select 
   Id,
   Max(datepart(Create) ) as Date format date9.
   From tedt1
   group by id
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;You code is showing a lot of syntax problems: period instead of comma between select items; a&amp;nbsp;semicolon in the middle of From; an extra comma at the end; and use of RUN instead of QUIT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I don't know what value of balance you want.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Dec 2018 20:46:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-12-07T20:46:42Z</dc:date>
    <item>
      <title>How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519524#M73356</link>
      <description>I have a table i need to get max date.&lt;BR /&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table test as&lt;BR /&gt;Select&lt;BR /&gt;Id.&lt;BR /&gt;Balance.&lt;BR /&gt;Max(Create ) as Date&lt;BR /&gt;Fr;m tedt1&lt;BR /&gt;,&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;It brings everything. The create is a datetime20 format. The output is converted to 1859756644</description>
      <pubDate>Fri, 07 Dec 2018 19:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519524#M73356</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2018-12-07T19:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519527#M73357</link>
      <description>&lt;P&gt;Can you plz post a sample of what you HAVE(Data) and what you want(Data) as output?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 19:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519527#M73357</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-07T19:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519532#M73359</link>
      <description>&lt;P&gt;You'll need to add a GROUP BY or HAVING clause depending what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want the record with the latest date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;select ID, Balance, Max(create) as max format=datetime20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;GROUP BY&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ID, Balance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;HAVING create=MAX(create)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or the max date for each ID/Balance combination?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;select ID, Balance, Max(Create) &lt;SPAN&gt;as max format=datetime20.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;GROUP BY&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ID, Balance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2012/09/18/having-clause-fun-with-sas-enterprise-guide/" target="_self"&gt;See&amp;nbsp;this post for another example.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 19:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519532#M73359</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-12-07T19:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519553#M73362</link>
      <description>&lt;P&gt;If you want the date portion of a variable containing datetime then the function is DATEPART(variable). You likely want to provide a date format to go along with that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something similar to&lt;/P&gt;
&lt;PRE&gt;Proc sql;
   Create table test as
   Select 
   Id,
   Max(datepart(Create) ) as Date format date9.
   From tedt1
   group by id
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;You code is showing a lot of syntax problems: period instead of comma between select items; a&amp;nbsp;semicolon in the middle of From; an extra comma at the end; and use of RUN instead of QUIT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I don't know what value of balance you want.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 20:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519553#M73362</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-07T20:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519878#M73375</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do id=1 to 10;
    balance=id*.452;
	create_dt=mdy(id,1,2018);
	output;
	if id&amp;gt;=7 then do;
    balance=id*.458;
	create_dt=mdy(id,1,2019);
	    output;
	end;

  end;
  format create_dt date9.;
run;

/* This will yield the same result */
proc sql;
  create table want as
  select 
  id,
  balance,
  max(create_dt) as max_crdt format=date9.
  from have
  group by id;
quit;

/* I think this is what you want */
proc sql;
  create table want as
  select 
  id,
  balance,
  create_dt
  from have
  group by id
  having max(create_dt)=create_dt;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 09:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/519878#M73375</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2018-12-10T09:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/520484#M73395</link>
      <description>Im still getting all of entries not the maxdate.&lt;BR /&gt;Proc sql ;&lt;BR /&gt;Create table table as&lt;BR /&gt;Select&lt;BR /&gt;Id,&lt;BR /&gt;Balance,&lt;BR /&gt;Created&lt;BR /&gt;From table1&lt;BR /&gt;Group by dnd,balance,created&lt;BR /&gt;Having created =max(created)&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Quit;&lt;BR /&gt;&lt;BR /&gt;The created data looks like this&lt;BR /&gt;Id. Balance. Created&lt;BR /&gt;101. 120. 10DEC2018:19:11:30&lt;BR /&gt;101. 500. 10DEC2018:18:11:56&lt;BR /&gt;&lt;BR /&gt;I would want&lt;BR /&gt;Id. Balance. Created&lt;BR /&gt;101. 120. 10DEC2018:19:11:30</description>
      <pubDate>Tue, 11 Dec 2018 18:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/520484#M73395</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2018-12-11T18:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max created date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/520488#M73396</link>
      <description>Got it thanks</description>
      <pubDate>Tue, 11 Dec 2018 18:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-max-created-date/m-p/520488#M73396</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2018-12-11T18:46:22Z</dc:date>
    </item>
  </channel>
</rss>

