<?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 Error paired with infield statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722434#M223991</link>
    <description>&lt;P&gt;SIZE is not set anywhere in your code. You will see a NOTE about that in the log ("uninitialized").&lt;/P&gt;</description>
    <pubDate>Sun, 28 Feb 2021 17:16:48 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-02-28T17:16:48Z</dc:date>
    <item>
      <title>Do Loop Error paired with infield statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722433#M223990</link>
      <description>&lt;P&gt;I' am trying to read in my data using an infile statement and then use a do loop to replicate the data several times based on the value of two variables, replicates and Samp. &amp;nbsp;When I add the do loop in, I get this error : v&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;expression is missing, zero, or invalid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea why this is happening. &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;For reference here is what the data looks like before:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; Replicate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Samp&amp;nbsp;&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and here is what I want it to look like afterwards:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; reps. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Samp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rep1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;samp1&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1329 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my current code to do this&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is formatted a little weird so the infile and do while loops are necessary to properly read in the data&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data carsim; 
	infile 'S:\sasdata\cars.txt' firstobs=2 dlm='09'x truncover ;
	input dist : $6.  reps :  samp  @ ;
	/*Remove any observations where size is missing*/
	do while(not missing(Samp));
		output;
		input Samp  @;
	end;


	/* rep1 = observation number within the sample*/ 
	/* samp1 = Sample Number 
	/*Replicate dataset according to rep and size variables*/
		do rep1 = 1 to reps by 1; 
			do samp1 = 1 to size by 1;
				output;
				
			end;
		end;
	

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Feb 2021 16:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722433#M223990</guid>
      <dc:creator>gleebglorb</dc:creator>
      <dc:date>2021-02-28T16:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Error paired with infield statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722434#M223991</link>
      <description>&lt;P&gt;SIZE is not set anywhere in your code. You will see a NOTE about that in the log ("uninitialized").&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2021 17:16:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722434#M223991</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-28T17:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Error paired with infield statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722435#M223992</link>
      <description>&lt;P&gt;Please show us the LOG (all of it for your data step, every single line of code plus NOTEs, WARNINGs and ERRORs of this data step, with nothing chopped out). Please do NOT show us errors disconnected from the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think we would also need to see&amp;nbsp; a portion of the input data from the .txt file, presented following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt; and not via any other method.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2021 17:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722435#M223992</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-28T17:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Error paired with infield statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722436#M223993</link>
      <description>&lt;P&gt;Do you really need to first DO loop?&amp;nbsp; That is do some of the lines of text have multiple SAMP values?&lt;/P&gt;
&lt;P&gt;If not then remove it.&lt;/P&gt;
&lt;P&gt;If yes then move the second DO loop inside the first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data carsim; 
	infile 'S:\sasdata\cars.txt' firstobs=2 dlm='09'x truncover ;
	input dist : $6.  reps :  samp  @ ;
	do while(not missing(Samp));
	/* rep1 = observation number within the sample*/ 
	/* samp1 = Sample Number 
	/*Replicate dataset according to rep and size variables*/
		do rep1 = 1 to reps by 1; 
			do samp1 = 1 to SAMP by 1;
				output;
			end;
		end;
		input Samp  @;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Feb 2021 17:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-Error-paired-with-infield-statement/m-p/722436#M223993</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-28T17:21:32Z</dc:date>
    </item>
  </channel>
</rss>

