<?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: fileexist function in UNIX in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281653#M57142</link>
    <description>Yes,  EG and Studio are configured to the UNIX servers...

For PC sas I access it through Samba and the execution happens through, signon to remote server and rsubmit.</description>
    <pubDate>Fri, 01 Jul 2016 08:14:38 GMT</pubDate>
    <dc:creator>DMoovendhan</dc:creator>
    <dc:date>2016-07-01T08:14:38Z</dc:date>
    <item>
      <title>fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281552#M57121</link>
      <description>Hi,

I am Using fileexist function to check if the a file is present in Unix location it is working fine, when I execute the code through eg or sas studio, but when I execute it through PC SAS it doesn't recognize the file.

When I use PC SAS, I get the program path and derive the file location as in accordance with the actual unix location and set it as a macro variable using SYSLPUT.

The libnames gets created perfectly with the path specified.

Even if I hard code the correct path it shows the value as 0, that the file is not present

I tried mutiple options

1.using filename reference
Filename prgconf "&amp;amp;path/config.csv";
%put %sysfunc(fileexist(prgconf);

2.macro variable
%put %sysfunc(fileexist(&amp;amp;path/config.csv);

3.direct hardcoded path
%put %sysfunc(fileexist(/infra/integ/config.csv);

but always the value is 0, how can I check the file presence, is there any other way.

Kindly help.

Thanks,
Moovendhan Devaraj</description>
      <pubDate>Thu, 30 Jun 2016 19:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281552#M57121</guid>
      <dc:creator>DMoovendhan</dc:creator>
      <dc:date>2016-06-30T19:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281586#M57129</link>
      <description>&lt;P&gt;It looks like your EG/Studio server is unix, and you have a different unix&amp;nbsp;userid when using the server via a client and when accessing the file from a PC via samba.&lt;/P&gt;
&lt;P&gt;Have you checked the authorisations on the file? and on the directory?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wait, do you actually use /infra/integ/config.csv on the PC?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 00:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281586#M57129</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-01T00:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281588#M57130</link>
      <description>&lt;P&gt;You mentioned %SYSLPUT so it sounds like you are using SAS/Connect. So make sure you know where you macro code is running.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(fileexist(/infra/integ/config.csv)); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;on your PC then the answer will always be 0 unless you have a file named&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;\infra\integ\config.csv&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;on whatever disk is the current working disk for the Windows process that is running SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 00:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281588#M57130</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-07-01T00:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281653#M57142</link>
      <description>Yes,  EG and Studio are configured to the UNIX servers...

For PC sas I access it through Samba and the execution happens through, signon to remote server and rsubmit.</description>
      <pubDate>Fri, 01 Jul 2016 08:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281653#M57142</guid>
      <dc:creator>DMoovendhan</dc:creator>
      <dc:date>2016-07-01T08:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281654#M57143</link>
      <description>the execution is in remote server through rsubmit after remore signon.

The file is present in the remote server.</description>
      <pubDate>Fri, 01 Jul 2016 08:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281654#M57143</guid>
      <dc:creator>DMoovendhan</dc:creator>
      <dc:date>2016-07-01T08:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281698#M57154</link>
      <description>&lt;P&gt;When I execute the function file exist with in macro itrs not working, when I execute iot as a separste code it works fine&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with in macro&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MPRINT(SETUP): rsubmit&lt;BR /&gt;NOTE: Remote submit to RMT.__7551 commencing.&lt;BR /&gt;MLOGIC(SETUP): %PUT&lt;BR /&gt; %sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibac&lt;BR /&gt; terial_antifungal/arw_sas_prgconfig.csv))&lt;BR /&gt;0&lt;BR /&gt;MPRINT(SETUP): ; x "pwd";&lt;BR /&gt;MPRINT(SETUP): endrsubmit;&lt;BR /&gt;NOTE: Current working directory is '/dmck1t/3rdparty/tpsandbox'.&lt;BR /&gt;1 x "pwd"&lt;BR /&gt;1 ! ;&lt;BR /&gt;NOTE: Remote submit to RMT.__7551 complete.&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;
&lt;P&gt;As separate code,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 %put&lt;BR /&gt;1 ! %sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibact&lt;BR /&gt;1 ! erial_antifungal/arw_sas_prgconfig.csv));&lt;BR /&gt;1&lt;BR /&gt;NOTE: Current working directory is '/dmck1t/3rdparty/tpsandbox'.&lt;BR /&gt;2 x "pwd"&lt;BR /&gt;2 ! ;&lt;BR /&gt;NOTE: Remote submit to RMT.__7551 complete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have hardcoded the paths in in both the places and its just a copy&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 12:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281698#M57154</guid>
      <dc:creator>DMoovendhan</dc:creator>
      <dc:date>2016-07-01T12:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281715#M57160</link>
      <description>&lt;P&gt;That's odd (i.e. doesn't make sense).&amp;nbsp; And I see you have rsubmit involved.&amp;nbsp; Can you try running both tests in a single submission?&amp;nbsp; That is, submit all of the following at once:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
  %PUT Inside macro: &amp;gt;&amp;gt;%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv))&amp;lt;&amp;lt;;
%mend test;

%test;
%PUT outside macro: &amp;gt;&amp;gt;%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv))&amp;lt;&amp;lt;;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the MLOGIC it looks like maybe you are missing a semicolon at the end of your %PUT statement in the macro?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 13:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/281715#M57160</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-07-01T13:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: fileexist function in UNIX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/285544#M58404</link>
      <description>&lt;P&gt;Thanks For your comment Quentin, in either of the cases it worked.&lt;/P&gt;
&lt;P&gt;But your comment helped me to think otherways and to resolve the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code was like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Macro chk1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%if &amp;lt;condition&amp;gt; %then %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Signon remote = &amp;lt;server&amp;gt; User = _prompt_ Pass_prompt_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;%IF&amp;nbsp;%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv)) %then %do;&lt;/P&gt;
&lt;P&gt;&amp;lt;Statements&amp;gt;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this code the macro was executing in the local system and the sas codes were executing in the remote system, so&amp;nbsp;during the execution fileexist was executing in the local machine and so it didn't find the file present.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tackled the issue by&amp;nbsp;creating a submacro after the remore login, as below, so the macro gets compiled and executed in the remote&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Macro chk1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%if &amp;lt;condition&amp;gt; %then %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Signon remote = &amp;lt;server&amp;gt; User = _prompt_ Pass_prompt_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;%macro rtp1;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;%IF&amp;nbsp;%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv)) %then %do;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&amp;lt;Statements&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;%mend rtp1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %rtp1;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 15:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fileexist-function-in-UNIX/m-p/285544#M58404</guid>
      <dc:creator>DMoovendhan</dc:creator>
      <dc:date>2016-07-19T15:37:46Z</dc:date>
    </item>
  </channel>
</rss>

