<?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 last service date in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531640#M22294</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.id, a.date, max(b.date) as servicedate format=yymmddd10.
from table_a a, table_b b
where a.id = b.id and b.date &amp;lt;= a.date
group by a.id, a.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 31 Jan 2019 14:14:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-01-31T14:14:57Z</dc:date>
    <item>
      <title>How to get last service date</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531635#M22293</link>
      <description>Hi i have 2 tables i need to compare service date from table a and determine the last service date from table b&lt;BR /&gt;Table a&lt;BR /&gt;Id. Date&lt;BR /&gt;A1. 01/02/19&lt;BR /&gt;D1. 01/15/19&lt;BR /&gt;A1. 01/24/19&lt;BR /&gt;D1 01/20/19&lt;BR /&gt;&lt;BR /&gt;Table b&lt;BR /&gt;&lt;BR /&gt;Id. Date&lt;BR /&gt;A1. 01/01/19&lt;BR /&gt;D1. 01/13/19&lt;BR /&gt;A1. 01/23/19&lt;BR /&gt;D1 01/18/19&lt;BR /&gt;Output&lt;BR /&gt;&lt;BR /&gt;Id. Date&lt;BR /&gt;A1. 01/02/19. A1. 01/01/19&lt;BR /&gt;D1. 01/15/19. D1. 01/13/19&lt;BR /&gt;A1. 01/24/19. A1. 01/23/19&lt;BR /&gt;D1 01/20/19. D1 01/18/19&lt;BR /&gt;&lt;BR /&gt;Thanks for assistance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Jan 2019 14:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531635#M22293</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2019-01-31T14:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get last service date</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531640#M22294</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.id, a.date, max(b.date) as servicedate format=yymmddd10.
from table_a a, table_b b
where a.id = b.id and b.date &amp;lt;= a.date
group by a.id, a.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 14:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531640#M22294</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-31T14:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get last service date</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531657#M22295</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input Id $ Date :	mmddyy10.;
format date mmddyy10.;
cards;
A1 01/02/19
D1 01/15/19
A1 01/24/19
D1 01/20/19
;

data b;
input Id $ Date :	mmddyy10.;
format date mmddyy10.;
cards;
A1 01/01/19
D1 01/13/19
A1 01/23/19
D1 01/18/19
;


data want;
set a;
if _n_=1 then do;
if 0 then set b(rename=(date=serv_date));
   declare hash H (dataset:'b(rename=(date=serv_date))',multidata:'y') ;
   h.definekey  ("id") ;
   h.definedata ("serv_date") ;
   h.definedone () ;
 end;
do rc=h.find() by 0 while(rc=0);
if 	serv_date&amp;lt;date then last_serv_date=max(serv_date,last_serv_date);
rc=	h.find_next();
end;
format 	last_serv_date mmddyy10.;
drop rc serv_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 15:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531657#M22295</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-31T15:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get last service date</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531693#M22296</link>
      <description>&lt;P&gt;Direct access&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input Id $ Date :	mmddyy10.;
format date mmddyy10.;
cards;
A1 01/02/19
D1 01/15/19
A1 01/24/19
D1 01/20/19
;

data b;
input Id $ Date :	mmddyy10.;
format date mmddyy10.;
cards;
A1 01/01/19
D1 01/13/19
A1 01/23/19
D1 01/18/19
;


data want;
set a ;
if _n_=1 then do;
if 0 then set b(rename=(date=last_serv_date));
   declare hash H (dataset:'b(rename=(date=last_serv_date))',multidata:'y',ordered:'d') ;
   h.definekey  ("id","last_serv_date") ;
   h.definedata ("last_serv_date") ;
   h.definedone () ;
   declare hiter hh('h');
 end;
rc=h.add(key:id,key:date,data:date);
rc = hh.setcur(key:id,key:date) ;
rc=hh.next();
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 16:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-get-last-service-date/m-p/531693#M22296</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-31T16:23:34Z</dc:date>
    </item>
  </channel>
</rss>

