<?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: %sysfunc(fileexist()) doesn't work with task scheduler in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719168#M222648</link>
    <description>&lt;P&gt;Impressive, Tom! You are right to the point! It worked! Really appreciate your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 14 Feb 2021 00:19:32 GMT</pubDate>
    <dc:creator>LisaXu</dc:creator>
    <dc:date>2021-02-14T00:19:32Z</dc:date>
    <item>
      <title>%sysfunc(fileexist()) doesn't work with task scheduler</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719157#M222642</link>
      <description>&lt;P&gt;I need to schedule a daily SAS program run to check existence of a file and process it. Somehow, when I run the program in PC SAS , it can get the correct results. But when I use the Windows Task Scheduler to run it, it comes back "File does not exist". Same program. Anyone has any idea what could be wrong? Thanks so much!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let FileRef="R:\&amp;amp;filename";&lt;BR /&gt;%put &amp;amp;FileRef;&lt;BR /&gt;/**"R:\Account_2021-02-11.txt"**/&lt;BR /&gt;%let FR=%sysfunc(dequote(&amp;amp;FileRef));&lt;BR /&gt;%put &amp;amp;FR;&lt;BR /&gt;/**R:\Account_2021-02-11.txt**/&lt;/P&gt;&lt;P&gt;%macro CheckFile;&lt;BR /&gt;%if %sysfunc(fileexist(&amp;amp;FR)) %then %do;&lt;BR /&gt;data aa ;&lt;BR /&gt;infile &amp;amp;FileRef firstobs=2;&lt;BR /&gt;;&lt;BR /&gt;input&amp;nbsp; ............&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %put The file &amp;amp;FileRef does not exist. ;&lt;BR /&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 22:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719157#M222642</guid>
      <dc:creator>LisaXu</dc:creator>
      <dc:date>2021-02-13T22:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: %sysfunc(fileexist()) doesn't work with task scheduler</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719162#M222646</link>
      <description>&lt;P&gt;What is R: ?&amp;nbsp; Most likely you have mapped some network share to that drive letter as you probably do not have that many physical hard disks on your computer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems likely that the scheduled job is running under a different user or at least setting up the Windows environment in a different way such that the R drive is not mapped (or if a different user then it does not have permission to see the requested file or the folder that holds it).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would first try using UNC instead of mapped drive.&amp;nbsp; So if R: is mapped to \\some-server\some-share then change the code to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let FileRef="\\some-server\some-share\&amp;amp;filename";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Feb 2021 22:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719162#M222646</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-13T22:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: %sysfunc(fileexist()) doesn't work with task scheduler</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719163#M222647</link>
      <description>&lt;P&gt;Thanks so much for your quick reply, Tom! Yes, the R drive is what I mapped to save the long path...I'll fix that and see...Thanks again!!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 22:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719163#M222647</guid>
      <dc:creator>LisaXu</dc:creator>
      <dc:date>2021-02-13T22:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: %sysfunc(fileexist()) doesn't work with task scheduler</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719168#M222648</link>
      <description>&lt;P&gt;Impressive, Tom! You are right to the point! It worked! Really appreciate your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 00:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sysfunc-fileexist-doesn-t-work-with-task-scheduler/m-p/719168#M222648</guid>
      <dc:creator>LisaXu</dc:creator>
      <dc:date>2021-02-14T00:19:32Z</dc:date>
    </item>
  </channel>
</rss>

