<?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 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645419#M78528</link>
    <description>&lt;P&gt;You are using a specialized do loop with a set statement inside the do loop. It can be done but you are not doing that correctly. You will have to understand the mechanism of the natural looping of the data step before moving on to do advance do loops.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also many different Shift index values. MONTH, WEEK and WEEK2 are the ones you need. Try the below and see if that works for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want ;
   set your_input_dataset ;
   _dte = last_billing_date ;
   format _dte next_payment_dte date9. ;
   if last_billing_date&amp;gt;. then 
   do until(next_payment_dte&amp;gt;="31May2020"d) ;
      if billing_mode=4 then next_payment_dte=intnx('month',_dte,1,"sameday");
      else if billing_mode=8 then next_payment_dte=intnx('week2',_dte,1,"sameday");
      else if billing_mode=7 then next_payment_dte=intnx('week',_dte,1,"sameday");
      _dte = next_payment_dte ;
      if next_payment_dte&amp;lt;="31May2020"d then output ;
   end ;
   if last_billing_date = . then output ;
run ;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2020 21:06:17 GMT</pubDate>
    <dc:creator>biopharma</dc:creator>
    <dc:date>2020-05-05T21:06:17Z</dc:date>
    <item>
      <title>do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645369#M78521</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;trying to populate all next payment dates till end of May for each billing mode+last billing date record&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4-monthly&lt;/P&gt;
&lt;P&gt;7-weekly&lt;/P&gt;
&lt;P&gt;8-bi weekly&lt;/P&gt;
&lt;P&gt;and i dont care about the records with missing last billing date. Can be removed&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;have:&lt;BR /&gt;billing mode last Billing date&lt;BR /&gt;---------------------------------&lt;BR /&gt;4 10-mar-2020&lt;BR /&gt;7 01-may-2020&lt;BR /&gt;7 15-may-2020&lt;BR /&gt;7&amp;nbsp; .&lt;BR /&gt;8 20-apr-2020&lt;BR /&gt;8&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;want:&lt;BR /&gt;billing mode last Billing date next payment date&lt;BR /&gt;---------------------------------------------------&lt;BR /&gt;4 10-mar-2020 10-apr-2020 &lt;BR /&gt;4 10-mar-2020 10-may-2020 &lt;BR /&gt;7 01-may-2020 08-may-2020&lt;BR /&gt;7 01-may-2020 15-may-2020&lt;BR /&gt;7 01-may-2020 22-may-2020&lt;BR /&gt;7 01-may-2020 29-may-2020&lt;BR /&gt;7 15-may-2020 22-may-2020&lt;BR /&gt;7 15-may-2020 29-may-2020&lt;BR /&gt;7&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;BR /&gt;8 20-apr-2020 04-may-2020&lt;BR /&gt;8 20-apr-2020 18-may-2020&lt;BR /&gt;8&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;i am&amp;nbsp; using&amp;nbsp; this below but it is not right. Looks like i need to use &lt;STRONG&gt;grouping by&lt;/STRONG&gt; along with the loop but i am&amp;nbsp; out of ideas&amp;nbsp; how . Any suggestions&amp;nbsp; pls?&amp;nbsp; thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt;next_payment_dte=Last_Billing_Date;&lt;BR /&gt;do until (next_payment_dte&amp;lt;='31May2020'd); &lt;BR /&gt;set have;&lt;BR /&gt;if billing_mode=4 then next_payment_dte=intnx('month',next_payment_dte,1,"sameday");&lt;BR /&gt;else if billing_mode=8 then next_payment_dte=intnx('day',next_payment_dte,14,"sameday");&lt;BR /&gt;else if billing_mode=7 then next_payment_dte=intnx('day',next_payment_dte,7,"sameday");&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 18:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645369#M78521</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-05-05T18:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645385#M78522</link>
      <description>&lt;P&gt;&lt;SPAN&gt;do until (next_payment_dte&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;='31May2020'd);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think you need greater than for starters, not less than for your condition. Note that for a DO UNTIL loop it will always evaluate at least once. Note that you do not have an output statement so if it loops more than once you won't have any billing dates generated except the last. You likely want to add an OUTPUT statement within the loop.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 19:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645385#M78522</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-05T19:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645419#M78528</link>
      <description>&lt;P&gt;You are using a specialized do loop with a set statement inside the do loop. It can be done but you are not doing that correctly. You will have to understand the mechanism of the natural looping of the data step before moving on to do advance do loops.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also many different Shift index values. MONTH, WEEK and WEEK2 are the ones you need. Try the below and see if that works for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want ;
   set your_input_dataset ;
   _dte = last_billing_date ;
   format _dte next_payment_dte date9. ;
   if last_billing_date&amp;gt;. then 
   do until(next_payment_dte&amp;gt;="31May2020"d) ;
      if billing_mode=4 then next_payment_dte=intnx('month',_dte,1,"sameday");
      else if billing_mode=8 then next_payment_dte=intnx('week2',_dte,1,"sameday");
      else if billing_mode=7 then next_payment_dte=intnx('week',_dte,1,"sameday");
      _dte = next_payment_dte ;
      if next_payment_dte&amp;lt;="31May2020"d then output ;
   end ;
   if last_billing_date = . then output ;
run ;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 21:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645419#M78528</guid>
      <dc:creator>biopharma</dc:creator>
      <dc:date>2020-05-05T21:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645467#M78529</link>
      <description>&lt;P&gt;i initially used do while and then&amp;nbsp; changed to&amp;nbsp; do until&amp;nbsp; but&amp;nbsp; forgot to change the&amp;nbsp; condition&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp; for your input.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 23:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645467#M78529</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-05-05T23:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645468#M78530</link>
      <description>&lt;P&gt;yea&amp;nbsp; this worked&lt;/P&gt;
&lt;P&gt;million thanks to both&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 23:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-until/m-p/645468#M78530</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-05-05T23:21:45Z</dc:date>
    </item>
  </channel>
</rss>

