<?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: Issue with the loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303620#M64525</link>
    <description>&lt;P&gt;Your solution is not working either. My observations are increasing. Below is the data I am looking forward too&lt;/P&gt;&lt;P&gt;Also if holiday is on weekend, then no need to add additional day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have ;&lt;BR /&gt;App Duedate&lt;BR /&gt;001 07/03/16&lt;BR /&gt;002 07/04/16&lt;BR /&gt;003 08/31/16&lt;BR /&gt;004 11/09/16&lt;BR /&gt;005 11/25/16&lt;BR /&gt;006 11/30/16&lt;BR /&gt;007 12/27/16&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;List of few holidays&lt;/P&gt;&lt;P&gt;05/25/15&lt;BR /&gt;07/04/15&lt;BR /&gt;05/30/16&lt;BR /&gt;07/04/16&lt;BR /&gt;09/05/16&lt;BR /&gt;10/10/16&lt;BR /&gt;11/11/16&lt;BR /&gt;11/24/16&lt;BR /&gt;12/25/16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data Want ;&lt;BR /&gt;App Duedate Updated&lt;BR /&gt;001 07/03/15 07/03/15&lt;BR /&gt;002 07/04/15 07/05/15&lt;BR /&gt;003 08/31/16 08/31/16&lt;BR /&gt;004 11/09/16 11/09/16&lt;BR /&gt;005 11/25/16 11/26/16&lt;BR /&gt;006 11/30/16 12/01/16&lt;BR /&gt;007 12/27/16 12/28/16&lt;/P&gt;</description>
    <pubDate>Mon, 10 Oct 2016 17:43:38 GMT</pubDate>
    <dc:creator>Di_Pat</dc:creator>
    <dc:date>2016-10-10T17:43:38Z</dc:date>
    <item>
      <title>Issue with the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303222#M64375</link>
      <description>&lt;P&gt;I am running below steps and output is not generated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 1) Converting Holidays into macro variable for last four years - so total 40 macro variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 2) Issue lies here - in do loop, check_4 is generating missing observations for all records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* For holiday, I am running below link with minor twerks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Generating_Holiday_Lists" target="_blank"&gt;http://www.sascommunity.org/wiki/Generating_Holiday_Lists&lt;/A&gt;&lt;/P&gt;&lt;P&gt;*/&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select count(*)&lt;BR /&gt;&amp;nbsp; into :NObs&lt;BR /&gt;&amp;nbsp; from holidays2;&lt;BR /&gt;&amp;nbsp; select Day_off&lt;BR /&gt;&amp;nbsp; into :Day_off1-:Day_off%left(&amp;amp;NObs)&lt;BR /&gt;&amp;nbsp; from holidays2;&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;day_off40 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* check_3 is mmddyy8. format, trying to add additional day if holiday falls on check_3 or within last three days of it */&lt;BR /&gt;data trial4 ;&lt;BR /&gt;set trial ;&lt;/P&gt;&lt;P&gt;do i = &amp;amp;day_off1. to &amp;amp;day_off40. ;&lt;BR /&gt;if check_3 - 1 = i then check_4 = check_3+1 ;&lt;BR /&gt;else if check_3 - 2 = i then check_4 = check_3+1 ;&lt;BR /&gt;else if check_3 - 3 = i then check_4 = check_3+1 ;&lt;BR /&gt;else if check_3 - 0 = i then check_4 = check_3+1 ;&lt;BR /&gt;else check_4 = check_3 ;&lt;BR /&gt;end;&lt;BR /&gt;format check_4 mmddyy8. ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp;suggest some good do loop documents as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 17:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303222#M64375</guid>
      <dc:creator>Di_Pat</dc:creator>
      <dc:date>2016-10-07T17:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303242#M64379</link>
      <description>&lt;P&gt;This is a wild guess since you really haven't shown us any of the data values. &amp;nbsp;You can confirm my guess in part by showing the results of the %PUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IF/THEN logic for creating CHECK4 always assigns it a value. &amp;nbsp;The only way it could be missing is if the DO loop never executes. &amp;nbsp;That could happen if you have dates in MM/DD/YY format for your 40 dates. &amp;nbsp;For example, the DO loop might actually look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=02/14/10 to 12/25/15;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That could conceivably be the results of substituting for your macro variables. &amp;nbsp;That DO loop won't execute at all, because the starting value is greater than the ending value. &amp;nbsp;All the "/" characters merely represent division, not a date. &amp;nbsp;So "2 divided by 14 divided by 10" is greater than "12 divided by 25 divided by 15" and the program skips executing the DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The right approach would be to load the 40 values into an array (macro language is optional, but not required). &amp;nbsp;Use a DO loop that goes from 1 to 40, each time referring to one of the elements in the array.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 18:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303242#M64379</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-07T18:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303248#M64381</link>
      <description>&lt;P&gt;You are absolutely right. format was creating the issue. Thank you for sparing time and explaining in detail. I bet I would have never found it in any documentation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New problem is --&amp;nbsp;else check_4 = check3 ; overwrites everything&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will have to write additional step to replace the missing dates.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 18:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303248#M64381</guid>
      <dc:creator>Di_Pat</dc:creator>
      <dc:date>2016-10-07T18:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303286#M64399</link>
      <description>&lt;P&gt;There really isn't a need to use the macro variable here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;into :Day_off1-:Day_off%left(&amp;amp;NObs)&lt;/P&gt;
&lt;P&gt;If you do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;into :Day_off1-:Day_off9999 SAS will only create those needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you later need the number involve you can get Nobs using SQLOBS macro varaible;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select Day_off
  into :Day_off1-:Day_off9999
  from holidays2;
quit;
%let Nobs = &amp;amp;sqlobs;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the loop might look like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i = &amp;amp;day_off1. to &amp;amp;&amp;amp;day_off&amp;amp;nobs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I understand what your are attempting the multiple IF may be replace with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i - check_3 le 3 then check_4=check_3+1;&lt;/P&gt;
&lt;P&gt;else check_4=check_3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;maybe the subtraction should be check_3 - i though. Hard to be sure without values and what the result should be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if those variabls are indeed dates then the macro variables will look more like 207123&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 20:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303286#M64399</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-07T20:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303472#M64473</link>
      <description>&lt;P&gt;Thanks for reply. Will try tomorrow and keep you posted. If it wont work then I will post some data to have a peek.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 20:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303472#M64473</guid>
      <dc:creator>Di_Pat</dc:creator>
      <dc:date>2016-10-09T20:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303620#M64525</link>
      <description>&lt;P&gt;Your solution is not working either. My observations are increasing. Below is the data I am looking forward too&lt;/P&gt;&lt;P&gt;Also if holiday is on weekend, then no need to add additional day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have ;&lt;BR /&gt;App Duedate&lt;BR /&gt;001 07/03/16&lt;BR /&gt;002 07/04/16&lt;BR /&gt;003 08/31/16&lt;BR /&gt;004 11/09/16&lt;BR /&gt;005 11/25/16&lt;BR /&gt;006 11/30/16&lt;BR /&gt;007 12/27/16&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;List of few holidays&lt;/P&gt;&lt;P&gt;05/25/15&lt;BR /&gt;07/04/15&lt;BR /&gt;05/30/16&lt;BR /&gt;07/04/16&lt;BR /&gt;09/05/16&lt;BR /&gt;10/10/16&lt;BR /&gt;11/11/16&lt;BR /&gt;11/24/16&lt;BR /&gt;12/25/16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data Want ;&lt;BR /&gt;App Duedate Updated&lt;BR /&gt;001 07/03/15 07/03/15&lt;BR /&gt;002 07/04/15 07/05/15&lt;BR /&gt;003 08/31/16 08/31/16&lt;BR /&gt;004 11/09/16 11/09/16&lt;BR /&gt;005 11/25/16 11/26/16&lt;BR /&gt;006 11/30/16 12/01/16&lt;BR /&gt;007 12/27/16 12/28/16&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 17:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-the-loop/m-p/303620#M64525</guid>
      <dc:creator>Di_Pat</dc:creator>
      <dc:date>2016-10-10T17:43:38Z</dc:date>
    </item>
  </channel>
</rss>

