<?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: INFILE statement &amp;quot;END&amp;quot; Variable Erroring in Macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512664#M138094</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if last %then %do;

 	output;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above logic does not seem to make much sense , are you trying to write the last observation of the by group to the output dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Nov 2018 18:12:12 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2018-11-13T18:12:12Z</dc:date>
    <item>
      <title>INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512659#M138091</link>
      <description>&lt;P&gt;Hi - I'm using an INFILE statement in a macro, and the message I am getting is, ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; last&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where "last" is being invoked is here as part of the INFILE statement (END = last). Any ideas what I'm doing wrong? This is simplified code to test the usage of "last." Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro countfil(dsn);
data &amp;amp;dsn;   length fil2read $1000;
    INFILE output TRUNCOVER ;
    INPUT name $1000.;/*Pull pipe in*/
    fil2read=name;
	INFILE dummy FILEVAR=fil2read DSD END=last missover FIRSTOBS=9 LENGTH=len ;
	
		%if last %then %do;

    	output;
	   %end;
run;
%mend countfil;&lt;BR /&gt;&lt;BR /&gt;filename output pipe 'ls -a /mypath/*.csv' ;&lt;BR /&gt;%countfil(datasetname);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Nov 2018 17:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512659#M138091</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2018-11-13T17:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512664#M138094</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if last %then %do;

 	output;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above logic does not seem to make much sense , are you trying to write the last observation of the by group to the output dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 18:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512664#M138094</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-11-13T18:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512671#M138096</link>
      <description>&lt;P&gt;last is a data step variable and therefore not available while the macro&amp;nbsp;&lt;STRONG&gt;pre&lt;/STRONG&gt;processor prepares program code.&lt;/P&gt;
&lt;P&gt;In the data step, use Base SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if last then output;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Nov 2018 18:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512671#M138096</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-13T18:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512695#M138101</link>
      <description>&lt;P&gt;When I take out the %'s and use the normal non-macro language, the dataset is empty (even though I see the PIPE pulling in files)? Any ideas what could be going wrong? I don't have any filters or subsetting criteria other than the "last".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eventually my goal is to output the total number of observations (in response to the last user's comment as to why this code is the way it is - I plan to add a counter once I prove "last" is working as a variable)&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 19:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512695#M138101</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2018-11-13T19:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512717#M138108</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro countfil(dsn);
data &amp;amp;dsn;   length fil2read $1000;
    INFILE output TRUNCOVER ;
    INPUT name $1000.;/*Pull pipe in*/
    fil2read=name;
	INFILE dummy FILEVAR=fil2read DSD
                   EOV=last    missover FIRSTOBS=9 LENGTH=len ;
	
		if last then output;
run;
%mend countfil;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Nov 2018 19:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512717#M138108</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-11-13T19:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512749#M138118</link>
      <description>&lt;P&gt;Yep I had something similar to that. I had to tweak something else, and it worked. Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 21:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512749#M138118</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2018-11-13T21:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE statement "END" Variable Erroring in Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512830#M138147</link>
      <description>&lt;P&gt;You are trying to use macro logic where you want data step logic.&lt;/P&gt;
&lt;P&gt;You have two INFILE statements.&lt;/P&gt;
&lt;P&gt;Which one are you trying to count?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note you need to test the LAST variable BEFORE the INPUT statement if you want to handle empty input (or in this case input with less than 10 lines).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get it to work WITHOUT macro first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;dsn;
  INFILE output TRUNCOVER ;
  INPUT name $1000.;
  fil2read=name;
  INFILE dummy FILEVAR=fil2read DSD END=last TRUNCOVER FIRSTOBS=9 LENGTH=len ;
  do cnt=1 by 1 while ( not last );
    input ;
  end;
  put name= cnt=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 04:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-statement-quot-END-quot-Variable-Erroring-in-Macro/m-p/512830#M138147</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-14T04:16:25Z</dc:date>
    </item>
  </channel>
</rss>

