<?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: DO UNTIL STATEMENT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375272#M89940</link>
    <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this, however it flags the records with the min_date within 4 months as well? I don't want to flag the starting dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2017 11:39:03 GMT</pubDate>
    <dc:creator>CamRutherford</dc:creator>
    <dc:date>2017-07-12T11:39:03Z</dc:date>
    <item>
      <title>DO UNTIL STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375267#M89935</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some code which shows multiple records per ID with a transaction date for each row. I want to perform a looped expression that will do the following...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Grouped by ID, beginning with the row that has the min(trans_date), flag all of those that fall within 4months after. However, on the next instance where the trans_date does not fall within 4months then repeat the expression with the amended min(trans_date) being this one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EG.&lt;/P&gt;&lt;PRE&gt;ID	TRAN_DATE	   WITHIN 4MTHS
MBR123	01JAN2017	   N
MBR123	12FEB2017	   Y
MBR123	01JUL2017	   N
MBR123	22JUL2017	   Y
MBR123	06AUG2017	   Y&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hope this makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Cam&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375267#M89935</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-07-12T11:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: DO UNTIL STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375270#M89938</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by id tran_date;
run;

data want;
set have;
by id;
retain min_date;
if first.id then min_date = tran_date;
if intck('month',min_date,tran_date) &amp;lt;= 4
then within_4 = 'Y';
else do;
  within_4 = 'N';
  min_date = tran_date;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375270#M89938</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-12T11:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: DO UNTIL STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375272#M89940</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this, however it flags the records with the min_date within 4 months as well? I don't want to flag the starting dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375272#M89940</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-07-12T11:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: DO UNTIL STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375274#M89942</link>
      <description>&lt;P&gt;Then you need to slightly expand the conditions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
retain min_date;
if first.id
then do;
  min_date = tran_date;
  within_4 = 'N';
end;
else do;
  if intck('month',min_date,tran_date) &amp;lt;= 4
  then within_4 = 'Y';
  else do;
    within_4 = 'N';
    min_date = tran_date;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375274#M89942</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-12T11:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: DO UNTIL STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375280#M89944</link>
      <description>&lt;P&gt;While Kurt has the right structure to the program, I strongly urge you to reconsider use of INTCK.&amp;nbsp; It probably does not measure "4 months" the way you expect that it would.&amp;nbsp; Here are couple of different versions that could replace it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if (tran_date - min_date) &amp;lt;= 120 then ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if tran_date &amp;lt;= intnx('month', min_date, 4, 's') then ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With INTCK, you will find (for example) that this interval is still measured as 4 months:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;min_date = 02Jan2017&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tran_date = 30May2017&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375280#M89944</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-12T12:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: DO UNTIL STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375281#M89945</link>
      <description>&lt;P&gt;Depending on your needs, you should give &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s suggestions a good look. Especially the method with the intnx function.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-UNTIL-STATEMENT/m-p/375281#M89945</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-12T12:16:45Z</dc:date>
    </item>
  </channel>
</rss>

