<?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 Combine the Amount based on date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combine-the-Amount-based-on-date/m-p/767635#M243397</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.testl;&lt;BR /&gt;infile datalines ;&lt;BR /&gt;input Policy_number:$8. Test_Rk:8. Version:8. Amt:8. from_dt:date. to_dt:date.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 10 1 300 '01Jan2006'd&amp;nbsp; '01Jan2034'd&lt;BR /&gt;1 10 1 700 '01Jan2035’d&amp;nbsp; '01Jun2035'd&lt;BR /&gt;1 10 1 300 '01Jan2034'd&amp;nbsp; '01Jan2035'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the above example. In which I want the output to be the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 10 1 300 '01JAN2006'd&amp;nbsp; '01JUN2035'd&lt;/P&gt;&lt;P&gt;1 10 1 700 '01JAN2035'd&amp;nbsp; '01JUN2035'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie. if the amount is the same for the subsequent&amp;nbsp; from_dt for the same&lt;/P&gt;&lt;P&gt;Policy_number,Test_Rk, Version then the periods must be combined to one bigger period(from_dt = min(from_dt) and to_dt = Max(to_dt)&amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1 10 1 300 '01JAN2006'd '01JUN2035'd&lt;/P&gt;&lt;P&gt;if the amount is different then don't combine&amp;nbsp;-&amp;nbsp; 1 10 1 700 '01JAN2035'd '01JUN2035'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks,&lt;/P&gt;&lt;P&gt;Jay&lt;/P&gt;</description>
    <pubDate>Tue, 14 Sep 2021 09:28:51 GMT</pubDate>
    <dc:creator>Jayaditya</dc:creator>
    <dc:date>2021-09-14T09:28:51Z</dc:date>
    <item>
      <title>Combine the Amount based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-the-Amount-based-on-date/m-p/767635#M243397</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.testl;&lt;BR /&gt;infile datalines ;&lt;BR /&gt;input Policy_number:$8. Test_Rk:8. Version:8. Amt:8. from_dt:date. to_dt:date.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 10 1 300 '01Jan2006'd&amp;nbsp; '01Jan2034'd&lt;BR /&gt;1 10 1 700 '01Jan2035’d&amp;nbsp; '01Jun2035'd&lt;BR /&gt;1 10 1 300 '01Jan2034'd&amp;nbsp; '01Jan2035'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the above example. In which I want the output to be the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 10 1 300 '01JAN2006'd&amp;nbsp; '01JUN2035'd&lt;/P&gt;&lt;P&gt;1 10 1 700 '01JAN2035'd&amp;nbsp; '01JUN2035'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie. if the amount is the same for the subsequent&amp;nbsp; from_dt for the same&lt;/P&gt;&lt;P&gt;Policy_number,Test_Rk, Version then the periods must be combined to one bigger period(from_dt = min(from_dt) and to_dt = Max(to_dt)&amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1 10 1 300 '01JAN2006'd '01JUN2035'd&lt;/P&gt;&lt;P&gt;if the amount is different then don't combine&amp;nbsp;-&amp;nbsp; 1 10 1 700 '01JAN2035'd '01JUN2035'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks,&lt;/P&gt;&lt;P&gt;Jay&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 09:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-the-Amount-based-on-date/m-p/767635#M243397</guid>
      <dc:creator>Jayaditya</dc:creator>
      <dc:date>2021-09-14T09:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the Amount based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-the-Amount-based-on-date/m-p/767649#M243404</link>
      <description>&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=testl;
by policy_number from_dt;
run;

data want;
do until (last.amt);
  set testl;
  by policy_number amt notsorted;
  if first.amt then f_dt = from_dt;
end;
from_dt = f_dt;
drop f_dt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 10:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-the-Amount-based-on-date/m-p/767649#M243404</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-14T10:32:09Z</dc:date>
    </item>
  </channel>
</rss>

