<?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: Infinite Loop Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311100#M67140</link>
    <description>More than one issue:&lt;BR /&gt;On windows I think filevar needs to provide a variable holding a single path (and a filename that could hold global chars*? ).&lt;BR /&gt;Is the default length of NEXTFILE wide enough to hold the required path\file name ?&lt;BR /&gt;I expect you need to reset the value of LASTOBS to zero as it will be retained.&lt;BR /&gt;</description>
    <pubDate>Fri, 11 Nov 2016 21:54:16 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2016-11-11T21:54:16Z</dc:date>
    <item>
      <title>Infinite Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311079#M67130</link>
      <description>&lt;P&gt;Hi, I have one question on infinite loop. There are two programs, which are shown below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does program A work fine but program B generates infinite loop? thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Program A:&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;filename qtr1 ('c:\sasuser\month1.dat''c:\sasuser\month2.dat' &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;'c:\sasuser\month3.dat');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;data work.firstqtr; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;infile qtr1; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;input Flight $ Origin $ Dest $ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;Date : date9. RevCargo : comma15.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Program B:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;data work.quarter; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;do Month = 9, 10, 11; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;nextfile="c:\sasuser\month" &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;!!compress(put(Month,2.)!!".dat",' '); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;do until (lastobs); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;infile temp filevar=nextfile end=lastobs; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;input Flight $ Origin $ Dest $ Date : date9. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;RevCargo : comma15.; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;output; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;end; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;end; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="Default"&gt;&lt;SPAN style="font-size: 8.5pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 20:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311079#M67130</guid>
      <dc:creator>MrBruce</dc:creator>
      <dc:date>2016-11-11T20:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Infinite Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311086#M67133</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;!!compress(put(Month,2.)!!".dat",' '); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Don't you mean&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;||put(Month,2.)||".dat";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You used exclamation marks. Why do you take the compress function?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 21:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311086#M67133</guid>
      <dc:creator>jefreytag</dc:creator>
      <dc:date>2016-11-11T21:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Infinite Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311100#M67140</link>
      <description>More than one issue:&lt;BR /&gt;On windows I think filevar needs to provide a variable holding a single path (and a filename that could hold global chars*? ).&lt;BR /&gt;Is the default length of NEXTFILE wide enough to hold the required path\file name ?&lt;BR /&gt;I expect you need to reset the value of LASTOBS to zero as it will be retained.&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Nov 2016 21:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311100#M67140</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2016-11-11T21:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Infinite Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311104#M67143</link>
      <description>&lt;P&gt;Is this a test?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS normally stops a data step when it reads past the end of the input data set or text file.&lt;/P&gt;
&lt;P&gt;Run this little example to see what I mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   put 'BEFORE INPUT' _n_= ;
   input  ;
   put 'AFTER INPUT' _n_ = ;
cards;
1
2
3
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your second data step the conditions on your DO loops prevent it from reading past the end of the data. So on iteration 1 it does DO MONTH=9,10,11 and then on iteration 2 it does it again, ad infinitum. &amp;nbsp;Add a STOP statement before the RUN statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 23:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infinite-Loop-Question/m-p/311104#M67143</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-11T23:06:00Z</dc:date>
    </item>
  </channel>
</rss>

