<?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: How filevar= option is used in infile statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/930051#M365932</link>
    <description>&lt;P&gt;Thanks you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; for sharing one more new method.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2024 05:16:34 GMT</pubDate>
    <dc:creator>DrAbhijeetSafai</dc:creator>
    <dc:date>2024-05-29T05:16:34Z</dc:date>
    <item>
      <title>How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929902#M365862</link>
      <description>&lt;P&gt;I am trying to understand how filevar= option is used in infile statement. I am able to understand that a different file each time (varying file, filevar) will be given to read and it is read sequentially. But I am not able to understand the exact syntax. I am sharing the syntax below which I am trying.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename qtr1 "path";
filename qtr2 "path";
filename qtr3 "path";

data new;
infile temp filevar = qtr1;
input A B C D;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A B C D are four columns in .dat file qtr1, qtr2 and qtr3 and they are getting read properly without filevar= option. But when I am using filevar=option, the error is shown that "Invalid physical name."&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I request to kindly guide me about this. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 05:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929902#M365862</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-28T05:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929903#M365863</link>
      <description>Consult the docu for the Infile statement. It’s explained in detail with sample code.</description>
      <pubDate>Tue, 28 May 2024 05:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929903#M365863</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-28T05:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929905#M365865</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;. Thanks for your response. I am looking at the documentation and at other places on internet for quite a long time. Maybe more than 3 hours. But still I am not able to find where I am making a mistake. I request you to kindly copy paste relevant example program here if possible so I can try it. I am trying many things but not able to understand how this option is working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 05:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929905#M365865</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-28T05:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929913#M365868</link>
      <description>&lt;P&gt;I can't explain this better than the docu section &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hosto390/n00nf3im9mpn0pn1u1g3wyj51vk6.htm" target="_self"&gt;Reading from Multiple External Files in Sequential Order&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Adopting the docu sample code to what you shared:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* sample 1 */
data new;
  infile datalines truncover;
  input qtr1 $500.;

  infile dummy filevar = qtr1 end=done;
  do while(not done);
    input A B C D;
  end;

datalines;
&amp;lt;path1&amp;gt;
&amp;lt;path2&amp;gt;
&amp;lt;path3&amp;gt;
;
run;

/* sample 2 */
data paths;
  infile datalines truncover;
  input qtr1 $500.;
datalines;
&amp;lt;path1&amp;gt;
&amp;lt;path2&amp;gt;
&amp;lt;path3&amp;gt;
;
run;

data new;
  set paths;
  infile dummy filevar = qtr1 end=done;
  do while(not done);
    input A B C D;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the docu explanation doesn't work for you then another option is to copy/paste above sample 1 code into chatGPT. Just tried and the explanation given there is also not too bad.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 06:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929913#M365868</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-28T06:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929922#M365870</link>
      <description>&lt;P&gt;Your argument to the FILEVAR option is qtr1.&lt;/P&gt;
&lt;P&gt;FILEVAR (&lt;STRONG&gt;file&lt;/STRONG&gt;name&amp;nbsp;&lt;STRONG&gt;var&lt;/STRONG&gt;iable) defines a&amp;nbsp;&lt;EM&gt;variable&lt;/EM&gt; (not a value!), and this variable has to contain a valid path to a file. Since you do not set qtr1 to such a value in your code, the step fails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A file reference (what you set with FILENAME) and a data step variable are two completely different things.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 06:38:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929922#M365870</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-05-28T06:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929955#M365887</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	infile datalines truncover;
	input path $200.;
	do until(end);
		infile temp filevar=path end=end;
		input;
		put _infile_;
	end;
datalines;
/home/sassrv/global/templates/envsetup.sas
/home/sassrv/global/templates/ibnkstmt.sas
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an example of me reading two sas programs, and printing the contents to the log.&lt;BR /&gt;Hope that helps&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 08:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929955#M365887</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-05-28T08:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929956#M365888</link>
      <description>&lt;P&gt;Many thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;for pointing out the mistake that it should be a data step variable and not fileref as I was considering in the filename statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sharing the correct programme below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;do qtr = 1 to 3 by 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nextfile = "path till qtr but not 1, 2 or 3"||put(qtr,1.)".dat";&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do until (eof);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;infile temp filevar = nextfile end=eof;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;input A B C D;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are 3 files at the location of path as - qtr1.dat, qtr2.dat and qtr3.dat which gets referred and are read sequentially because of the above programme.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An online reference gave me idea that two do loops will be required and my colleague Sushil helped me in this.&amp;nbsp; Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; once again for finding out the exact mistake I was doing (misunderstanding about fileref and a variable in data step) which solved the problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 09:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929956#M365888</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-28T09:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929957#M365889</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464333"&gt;@Mazi&lt;/a&gt;&amp;nbsp;for the example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 08:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929957#M365889</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-28T08:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929979#M365896</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27897"&gt;@DrAbhijeetSafai&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to understand how filevar= option is used in infile statement. I am able to understand that a different file each time (varying file, filevar) will be given to read and it is read sequentially. But I am not able to understand the exact syntax. I am sharing the syntax below which I am trying.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename qtr1 "path";
filename qtr2 "path";
filename qtr3 "path";

data new;
infile temp filevar = qtr1;
input A B C D;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A B C D are four columns in .dat file qtr1, qtr2 and qtr3 and they are getting read properly without filevar= option. But when I am using filevar=option, the error is shown that "Invalid physical name."&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I request to kindly guide me about this. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to read three files as one then just change your FILENAME statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename qtr ("path1","path2","path3");

data new;
  infile qtr ;
  input A B C D;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to use FILEVAR then you want something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
  length qtr $200;
  do qtr="path1","path2","path3":
    infile temp filevar = qtr1 end=eof;
    do while (not eof);
      input A B C D;
      output;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2024 14:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/929979#M365896</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-28T14:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/930051#M365932</link>
      <description>&lt;P&gt;Thanks you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; for sharing one more new method.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 05:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/930051#M365932</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-29T05:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How filevar= option is used in infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/930064#M365936</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename qtr ("path1","path2","path3");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;Just wanted to add here that the comma after "path1" and "path2" are optional and it works even if these commas are not used and only space is given.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 07:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-filevar-option-is-used-in-infile-statement/m-p/930064#M365936</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-29T07:01:33Z</dc:date>
    </item>
  </channel>
</rss>

