<?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 flag the latest date or use group by in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437503#M108947</link>
    <description>&lt;P&gt;I have used sql same can be done in data step using group by and first or last clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd truncover;
input CASE_ID Activity_Creator:$30. Decisioned_By:$40. Suspect_Reason:$40. Agency_Date:datetime21.;
format Agency_Date datetime21.;
datalines;
25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,06FEB2018:15:35:14.00
25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,06FEB2018:15:33:00.00
14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,SALARY SLIP VERIFICATION,01NOV2017:15:33:41.00
14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,VERIFICATION OF SALARY SLIP,01NOV2017:15:40:11.00
;
run;

proc sql;
create table want as
select a.* 
from have a, 
	(select CASE_ID,max(Agency_Date) as dtm from have group by CASE_ID) b 
where  a.CASE_ID=b.CASE_ID and a.Agency_Date=b.dtm;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Feb 2018 10:59:21 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2018-02-15T10:59:21Z</dc:date>
    <item>
      <title>How to flag the latest date or use group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437428#M108908</link>
      <description>&lt;P&gt;Hi I want to use the following dates and the record associated with it following is the data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CASE_ID,Activity_Creator,Decisioned_By,comment,Suspect_Reason,Agency_Date&lt;BR /&gt;25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,&lt;FONT color="#FF0000"&gt;06FEB2018:15:35:14.00&lt;/FONT&gt;&lt;BR /&gt;25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,06FEB2018:15:33:00.00&lt;BR /&gt;14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,SALARY SLIP VERIFICATION,01NOV2017:15:33:41.00&lt;BR /&gt;14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,VERIFICATION OF SALARY SLIP,&lt;FONT color="#FF0000"&gt;01NOV2017:15:40:11.00&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;need to fetch only the dates and records associated with that date in red.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Also need to know how can we flag it as 1 and the same date with least time as 0&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;and how can we use group by statement in querry builder and base.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 06:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437428#M108908</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-02-15T06:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag the latest date or use group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437503#M108947</link>
      <description>&lt;P&gt;I have used sql same can be done in data step using group by and first or last clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd truncover;
input CASE_ID Activity_Creator:$30. Decisioned_By:$40. Suspect_Reason:$40. Agency_Date:datetime21.;
format Agency_Date datetime21.;
datalines;
25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,06FEB2018:15:35:14.00
25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,06FEB2018:15:33:00.00
14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,SALARY SLIP VERIFICATION,01NOV2017:15:33:41.00
14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,VERIFICATION OF SALARY SLIP,01NOV2017:15:40:11.00
;
run;

proc sql;
create table want as
select a.* 
from have a, 
	(select CASE_ID,max(Agency_Date) as dtm from have group by CASE_ID) b 
where  a.CASE_ID=b.CASE_ID and a.Agency_Date=b.dtm;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2018 10:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437503#M108947</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-02-15T10:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag the latest date or use group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437691#M109029</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106991"&gt;@anirudhs&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi I want to use the following dates and the record associated with it following is the data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CASE_ID,Activity_Creator,Decisioned_By,comment,Suspect_Reason,Agency_Date&lt;BR /&gt;25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,&lt;FONT color="#ff0000"&gt;06FEB2018:15:35:14.00&lt;/FONT&gt;&lt;BR /&gt;25412,RAPID INVESTIGATION SERVICES,Agency,CREDIT REFER,06FEB2018:15:33:00.00&lt;BR /&gt;14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,SALARY SLIP VERIFICATION,01NOV2017:15:33:41.00&lt;BR /&gt;14284,SHARP EAGLE INVESTIGATION PVT LTD,Agency,VERIFICATION OF SALARY SLIP,&lt;FONT color="#ff0000"&gt;01NOV2017:15:40:11.00&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;need to fetch only the dates and records associated with that date in red.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Also need to know how can we flag it as 1 and the same date with least time as 0&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;and how can we use group by statement in querry builder and base.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just to share a pet peeve: Those highlighted values are not dates they are &lt;STRONG&gt;datetime&lt;/STRONG&gt; values. With SAS data this is important as datetimes are measured in seconds and dates are measure in days. If you apply DATE functions, such as Year, moth, day or such intervals with functions like intnx or intck then the results are usually incredibly wrong. So using the proper DATETIME terminology will yield suggestions using the appropriate functions or parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And consider you have said "fetch only the dates and records associated with that date in red". so for &lt;FONT color="#ff0000"&gt;01NOV2017:15:40:11.00&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;do you also want the value if the "date" is &lt;FONT color="#ff0000"&gt;01NOV2017:13:21:11.00&lt;/FONT&gt; or not for that id value? If not then the TIME of day is important.&lt;/P&gt;
&lt;P&gt;But since you said "date" I would expect you to be requesting all the values for the DATE portion of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 16:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437691#M109029</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-15T16:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag the latest date or use group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437882#M109117</link>
      <description>sorry for this ... yes i want on the base of datetime values.</description>
      <pubDate>Fri, 16 Feb 2018 05:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437882#M109117</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-02-16T05:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag the latest date or use group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437899#M109119</link>
      <description>Have you seen the solution provided based on datetime and your requirement?</description>
      <pubDate>Fri, 16 Feb 2018 06:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-the-latest-date-or-use-group-by/m-p/437899#M109119</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-02-16T06:50:10Z</dc:date>
    </item>
  </channel>
</rss>

