<?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 %Do %while loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307251#M65776</link>
    <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do while loop is going more than it should be in a macro. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sysparm has filenames reading from unix which are tilda(~) delimited. Each File names are of&amp;nbsp;30 characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is going till 135 loops though i am pssing 2 files for testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA UNIX_FILES;&lt;BR /&gt;length MANUAL_FILES $32767;&lt;BR /&gt;%LET i=1;&lt;/P&gt;&lt;P&gt;%do %while (&amp;amp;i &amp;lt;= (%length(compress("&amp;amp;sysparm",'~','k')) +1));&lt;BR /&gt;%let MANUAL_FILES = %scan("&amp;amp;sysparm",&amp;amp;i,"~");&lt;/P&gt;&lt;P&gt;&amp;nbsp; etc&lt;/P&gt;&lt;P&gt;%let i = %eval(&amp;amp;i+1);&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MEND;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Oct 2016 21:04:54 GMT</pubDate>
    <dc:creator>SASAna</dc:creator>
    <dc:date>2016-10-25T21:04:54Z</dc:date>
    <item>
      <title>%Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307251#M65776</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do while loop is going more than it should be in a macro. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sysparm has filenames reading from unix which are tilda(~) delimited. Each File names are of&amp;nbsp;30 characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is going till 135 loops though i am pssing 2 files for testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA UNIX_FILES;&lt;BR /&gt;length MANUAL_FILES $32767;&lt;BR /&gt;%LET i=1;&lt;/P&gt;&lt;P&gt;%do %while (&amp;amp;i &amp;lt;= (%length(compress("&amp;amp;sysparm",'~','k')) +1));&lt;BR /&gt;%let MANUAL_FILES = %scan("&amp;amp;sysparm",&amp;amp;i,"~");&lt;/P&gt;&lt;P&gt;&amp;nbsp; etc&lt;/P&gt;&lt;P&gt;%let i = %eval(&amp;amp;i+1);&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MEND;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 21:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307251#M65776</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-10-25T21:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: %Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307254#M65777</link>
      <description>&lt;P&gt;You have more than one error here, related to how macro language executes functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easier error to clean up concerns %SCAN.&amp;nbsp; Macro language does not need quotes around character strings.&amp;nbsp; The double quotes should all be removed.&amp;nbsp; In this case, a lucky accident occurred.&amp;nbsp; The third parameter is telling %SCAN to use both double quotes and tildas as delimiters.&amp;nbsp; So the extra double quotes around &amp;amp;SYSPARM are being treated as delimiters and end up not being harmful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The crucial error concerns COMPRESS.&amp;nbsp; Macro language does not execute DATA step functions.&amp;nbsp; To macro language, "compress" is just a set of characters.&amp;nbsp; If you want macro language to execute a DATA step function, you have to add %SYSFUNC.&amp;nbsp; It works with most (not all) data step functions.&amp;nbsp; Once you get macro language to execute the function, the quotes must again be removed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do %while (&amp;amp;i &amp;lt;= (%length(%SYSFUNC(compress(&amp;amp;sysparm,~,k))) +1));&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 21:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307254#M65777</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-25T21:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: %Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307339#M65806</link>
      <description>&lt;P&gt;You can simply your code:&lt;/P&gt;
&lt;PRE&gt;data unix_files;
  length manual_files $30;
  do i=1 to countw("&amp;amp;sysparm.","~");
    manual_files=scan("&amp;amp;sysparm.",i,"~");
    output;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;If you need to do something, then replace the output step with a call execute() to either generate the code, or call a macro with manual_files as parameter.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 08:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307339#M65806</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-26T08:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: %Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307406#M65832</link>
      <description>Thank you, worked like charm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 26 Oct 2016 14:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/307406#M65832</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-10-26T14:07:09Z</dc:date>
    </item>
  </channel>
</rss>

