<?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: timing issues with filename function and infile statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828085#M327111</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223838"&gt;@js5&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are essentially correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "rc=filename(....)" statement is an executable statement - i.e. it won't be honored until the data step begins data processing.&amp;nbsp; After all, like all functions, it could be a result of an "IF ... THEN rc=filename(...)" statement, which means it can only be executed during actual data processin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the INFILE statement in your initial code is effectively a compile-time statement that must be established prior to execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the "filevar=" option tells SAS that it must be prepared to dynamically assign a physical file to a fileref (even if it is just a single unchanging assignment).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2022 12:48:16 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-08-10T12:48:16Z</dc:date>
    <item>
      <title>timing issues with filename function and infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828073#M327106</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having issues getting the filename function and infile statement to work nicely within one data step. The following code results in an error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ERROR: No logical assign for filename PWFILE.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;rc = filename("pwfile", catx("\", pathname("path"), "Password.txt"));
infile pwfile;
input password;
rc = filename("pwfile");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It is as if there is a timing issue with the fileref not being defined when infile wants to use it. I was able to work it around as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;password_file = catx("\", pathname("path"), "Password.txt");
infile dummy filevar=password_file;
input password;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It feels strange to use filevar to read only one file though. Is this behaviour expected? I cannot use filename statement beforehand because the code looks through the folder tree and only defines the fileref when it finds the latest folder. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 12:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828073#M327106</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2022-08-10T12:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: timing issues with filename function and infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828084#M327110</link>
      <description>&lt;P&gt;Look at FILEVAR=.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://v8doc.sas.com/sashtml/lgref/z0146932.htm#z0166950" target="_blank"&gt;https://v8doc.sas.com/sashtml/lgref/z0146932.htm#z0166950&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know this is an old link, but it is the one I could easily find.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 12:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828084#M327110</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2022-08-10T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: timing issues with filename function and infile statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828085#M327111</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223838"&gt;@js5&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are essentially correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "rc=filename(....)" statement is an executable statement - i.e. it won't be honored until the data step begins data processing.&amp;nbsp; After all, like all functions, it could be a result of an "IF ... THEN rc=filename(...)" statement, which means it can only be executed during actual data processin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the INFILE statement in your initial code is effectively a compile-time statement that must be established prior to execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the "filevar=" option tells SAS that it must be prepared to dynamically assign a physical file to a fileref (even if it is just a single unchanging assignment).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 12:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/timing-issues-with-filename-function-and-infile-statement/m-p/828085#M327111</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-08-10T12:48:16Z</dc:date>
    </item>
  </channel>
</rss>

