<?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 Loop and INFILE FILEVAR Together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773155#M245553</link>
    <description>&lt;P&gt;Really, describe the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case it is an infinite loop. I set the I loop to do 1 to 2. Then canceled (Ctrl-Break cancel data step) after minute or so. Then run this bit of code.&lt;/P&gt;
&lt;PRE&gt;data junk;
  set page;
  by i notsorted;
  Row=_n_;
  if first.i or last.i;
run;&lt;/PRE&gt;
&lt;P&gt;Which with proc print for my alloted time yields:&lt;/P&gt;
&lt;PRE&gt;--------------------------------------------------------------------------------------------------

i       Row

1         1
1      8331
2      8332
2     16741
1     16742
1     25072
2     25073
2     33482
1     33483
1     41813
2     41814
2     50223
1     50224
1     58554
2     58555
2     66964
1     66965
1     75295
2     75296
2     83705
1     83706
1     92036
2     92037
2    100446
&lt;/PRE&gt;
&lt;P&gt;A quick analysis of the above shows that the line intervals for I are the same for each value of i, in other words the input is getting read repeatedly without stopping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this approach which follows the second example of using Filevar in reading multiple files in the documentation.&lt;/P&gt;
&lt;PRE&gt;data add;
   length address $ 200;
	do i=1 to 2;
		address=cats("https://communities.sas.com/t5/forums/recentpostspage/post-type/thread/page/",i);
      output;
   end;
run;
data page(compress=char);
      set add;
		infile dummy url filevar=address truncover end=j;
		do until(j);
			input page $32767.;
			output;
		end;
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Oct 2021 21:10:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-10-08T21:10:36Z</dc:date>
    <item>
      <title>DO Loop and INFILE FILEVAR Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773141#M245548</link>
      <description>&lt;P&gt;A SAS Communities page can be easily read as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data page(compress=char);
	do i=1 to 1;
		address=cats("https://communities.sas.com/t5/forums/recentpostspage/post-type/thread/page/",i);
		infile dummy url filevar=address truncover end=j;
		do until(j);
			input page $32767.;
			output;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the code becomes incorrect if I change DO I=1 TO 1; to DO I=1 TO 10; instead.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data page(compress=char);
	do i=1 to 10;
		address=cats("https://communities.sas.com/t5/forums/recentpostspage/post-type/thread/page/",i);
		infile dummy url filevar=address truncover end=j;
		do until(j);
			input page $32767.;
			output;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can't I repeat INFILE FILEVAR inside DO loops? Though I know that the following code works correctly, I want to know where I'm misunderstanding.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data page;
	do i=1 to 10;
		output;
	end;
run;

data page(compress=char);
	set page;
	address=cats("https://communities.sas.com/t5/forums/recentpostspage/post-type/thread/page/",i);
	infile dummy url filevar=address truncover end=j;
	do until(j);
		input page $32767.;
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 19:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773141#M245548</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2021-10-08T19:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: DO Loop and INFILE FILEVAR Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773146#M245550</link>
      <description>What errors are you getting? &lt;BR /&gt;&lt;BR /&gt;The example of a similar type of problem in the documentation does separate the two steps for sure (Example 10 on the INFILE statement in the documentation).</description>
      <pubDate>Fri, 08 Oct 2021 20:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773146#M245550</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-08T20:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: DO Loop and INFILE FILEVAR Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773155#M245553</link>
      <description>&lt;P&gt;Really, describe the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case it is an infinite loop. I set the I loop to do 1 to 2. Then canceled (Ctrl-Break cancel data step) after minute or so. Then run this bit of code.&lt;/P&gt;
&lt;PRE&gt;data junk;
  set page;
  by i notsorted;
  Row=_n_;
  if first.i or last.i;
run;&lt;/PRE&gt;
&lt;P&gt;Which with proc print for my alloted time yields:&lt;/P&gt;
&lt;PRE&gt;--------------------------------------------------------------------------------------------------

i       Row

1         1
1      8331
2      8332
2     16741
1     16742
1     25072
2     25073
2     33482
1     33483
1     41813
2     41814
2     50223
1     50224
1     58554
2     58555
2     66964
1     66965
1     75295
2     75296
2     83705
1     83706
1     92036
2     92037
2    100446
&lt;/PRE&gt;
&lt;P&gt;A quick analysis of the above shows that the line intervals for I are the same for each value of i, in other words the input is getting read repeatedly without stopping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this approach which follows the second example of using Filevar in reading multiple files in the documentation.&lt;/P&gt;
&lt;PRE&gt;data add;
   length address $ 200;
	do i=1 to 2;
		address=cats("https://communities.sas.com/t5/forums/recentpostspage/post-type/thread/page/",i);
      output;
   end;
run;
data page(compress=char);
      set add;
		infile dummy url filevar=address truncover end=j;
		do until(j);
			input page $32767.;
			output;
		end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Oct 2021 21:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-Loop-and-INFILE-FILEVAR-Together/m-p/773155#M245553</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-08T21:10:36Z</dc:date>
    </item>
  </channel>
</rss>

