<?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 to check existence of files on UNIX server (FTP access)? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364583#M274867</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124456"&gt;@user_&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Your code is pretty close to what's documented in the SAS Note.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you could eventually get such an Error if the directory you want to list doesn't exist. May be use an absolute path as value for your CD parameter and ensure that this path exists (i.e. via WinSCP or Putty).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this doesn't work and no one else can shed light on it then contact SAS TechSupport. Provide your real code, the log and also reference the SAS Note which provided the code template.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once resolved please let us know the solution so we can learn something.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2017 14:04:51 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-06-06T14:04:51Z</dc:date>
    <item>
      <title>How to check existence of files on UNIX server (FTP access)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/363099#M274864</link>
      <description>&lt;P&gt;I have a list of files, say MyFiles. A sample file in the list&amp;nbsp;would be &lt;FONT face="Courier New"&gt;C:\user\docs\Letter.csv&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;I am able to check the existence by the following macro:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Check();

proc sql noprint;
select Files, count(Files) into :list separated by "#", :cnt from MyFiles;
quit;

%do i= 1 %to &amp;amp;cnt ;
	%let file=%scan(&amp;amp;list.,&amp;amp;i., '#');
		%if %sysfunc(fileexist(&amp;amp;file.)) %then %do; 
		%end; 
		%else %do ; 
		%put ------The file &amp;amp;file. doesn’t exist.---------; 
		%end ; 
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How&amp;nbsp;can I&amp;nbsp;do the same for files located on&amp;nbsp;remote&amp;nbsp;UNIX&amp;nbsp;server&amp;nbsp;that I&amp;nbsp;access via&amp;nbsp;FTP?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/363099#M274864</guid>
      <dc:creator>user_</dc:creator>
      <dc:date>2017-05-31T14:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of files on UNIX server (FTP access)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364105#M274865</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124456"&gt;@user_&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It appears you have a SAS dataset &lt;EM&gt;MyFiles&lt;/EM&gt; which contains a list of expected files. You then check if these files actually exists using function FILEEXIST().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I know this function doesn't work via FTP so you need to approach this differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should your files on the remote server all exist in a single or only a few directories then you could create a&amp;nbsp;directory listing of these remote folders and compare it with your expected files in &lt;EM&gt;MyFiles&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here the code to create such a directory listing: &lt;A href="https://support.sas.com/kb/43/962.html" target="_blank"&gt;http://support.sas.com/kb/43/962.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 13:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364105#M274865</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-06T13:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of files on UNIX server (FTP access)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364580#M274866</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your reply.&lt;/P&gt;&lt;P&gt;I have tried&amp;nbsp;to create a&amp;nbsp;&lt;SPAN&gt;directory listing of my files by the following code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME ftp1 FTP '' LS HOST='myHost'
cd='myDirectory'
user='myUserName' prompt;

data;
infile ftp1;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After entering my password, I get the following error:&amp;nbsp;ERROR: Invalid Reply received for the STOR command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any suggestion?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 13:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364580#M274866</guid>
      <dc:creator>user_</dc:creator>
      <dc:date>2017-06-06T13:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of files on UNIX server (FTP access)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364583#M274867</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124456"&gt;@user_&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Your code is pretty close to what's documented in the SAS Note.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you could eventually get such an Error if the directory you want to list doesn't exist. May be use an absolute path as value for your CD parameter and ensure that this path exists (i.e. via WinSCP or Putty).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this doesn't work and no one else can shed light on it then contact SAS TechSupport. Provide your real code, the log and also reference the SAS Note which provided the code template.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once resolved please let us know the solution so we can learn something.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 14:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-existence-of-files-on-UNIX-server-FTP-access/m-p/364583#M274867</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-06T14:04:51Z</dc:date>
    </item>
  </channel>
</rss>

