<?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 Date formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378501#M90969</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have the below data :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
input CustomerId $1-6 ScoreCardId 7-11 CustomerCreditGrade $13-16
ScoreCardDate $18-27 ScoreCardApprovedFlag $;
informat ScoreCardDate ddmmyy10.;
format ScoreCardDate yymmdd10.;
cards;
X1111 32104 AA+ 31/12/2016 Y
X1111 32105 AAA 31/03/2017 N
X1111 32103 AA 30/6/2106 Y
X1111 32102 AA- 31/03/2016 Y
X2222 40321 BBB 31/12/2016 N
X2222 40322 BBB+ 31/12/2016 Y
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;X1111 32105 AAA 31/03/2017 N
X2222 40321 BBB 31/12/2016 N
X2222 40322 BBB+ 31/12/2016 Y&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the code which I tried:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test3 as
select CustomerId,ScoreCardId,CustomerCreditGrade,ScoreCardDate,
ScoreCardApprovedFlag
from test2 group by CustomerId
having ScoreCardDate=max(ScoreCardDate) ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output which am getting is attached below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10482iB8DA297D8377A3A6/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture (4).PNG" title="Capture (4).PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 23 Jul 2017 13:56:53 GMT</pubDate>
    <dc:creator>molla</dc:creator>
    <dc:date>2017-07-23T13:56:53Z</dc:date>
    <item>
      <title>Date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378501#M90969</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have the below data :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
input CustomerId $1-6 ScoreCardId 7-11 CustomerCreditGrade $13-16
ScoreCardDate $18-27 ScoreCardApprovedFlag $;
informat ScoreCardDate ddmmyy10.;
format ScoreCardDate yymmdd10.;
cards;
X1111 32104 AA+ 31/12/2016 Y
X1111 32105 AAA 31/03/2017 N
X1111 32103 AA 30/6/2106 Y
X1111 32102 AA- 31/03/2016 Y
X2222 40321 BBB 31/12/2016 N
X2222 40322 BBB+ 31/12/2016 Y
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;X1111 32105 AAA 31/03/2017 N
X2222 40321 BBB 31/12/2016 N
X2222 40322 BBB+ 31/12/2016 Y&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the code which I tried:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test3 as
select CustomerId,ScoreCardId,CustomerCreditGrade,ScoreCardDate,
ScoreCardApprovedFlag
from test2 group by CustomerId
having ScoreCardDate=max(ScoreCardDate) ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output which am getting is attached below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10482iB8DA297D8377A3A6/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture (4).PNG" title="Capture (4).PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jul 2017 13:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378501#M90969</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2017-07-23T13:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378517#M90979</link>
      <description>&lt;P&gt;Your difficulties begin with the fact that you made the date a character variable. &amp;nbsp;Get rid of the dollar sign here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ScoreCardDate $18-27&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That might be enough to fix everything.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jul 2017 10:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378517#M90979</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-23T10:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378534#M90989</link>
      <description>&lt;P&gt;You data does not appear to be in fixed columns like you INPUT statement is assuming. Perhaps it really is, but the formatting was lost when you pasted the code into the text box instead of using the Insert SAS code pop-up text window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have editted you message to use &amp;nbsp;SAS code boxes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not read your dates as strings. &amp;nbsp;You should have gotten an note that SAS couldn't find the $DDMMYY informat.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jul 2017 14:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378534#M90989</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-23T14:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378544#M90992</link>
      <description>Making ScoreCardDate a numeric variable should fix the issue.&lt;BR /&gt;Here since the varible is a charecter variable when you use max it takes the value of variable with max frequency as it cannot determine the max of string values</description>
      <pubDate>Sun, 23 Jul 2017 17:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-formats/m-p/378544#M90992</guid>
      <dc:creator>Bipasha</dc:creator>
      <dc:date>2017-07-23T17:44:42Z</dc:date>
    </item>
  </channel>
</rss>

