<?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: Unix Files capture through SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624091#M183780</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134610"&gt;@Banu&lt;/a&gt;&amp;nbsp; - Moving SAS data between SAS servers is a LOT easier if you have a SAS/CONNECT installed on all of them and USE PROC UPLOAD and DOWNLOAD. The SAS logs from these jobs then become the audit trails for your data transfers.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Feb 2020 07:18:45 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2020-02-12T07:18:45Z</dc:date>
    <item>
      <title>Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624081#M183773</link>
      <description>&lt;DIV class="gs"&gt;&lt;DIV class=""&gt;&lt;DIV class="ii gt"&gt;&lt;DIV class="a3s aXjCH "&gt;&lt;DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am new to SAS and got one requirement to automate one manual task. I have multiple servers like 'A','B','C','D'. Here 'A' is the Cenrtal server which has SFTP/SSH connections to all B,C &amp;amp; D servers. We have monthly jobs in 'B server which outputs SAS dataset in 'B' server and then SFTP to the 'A' server. From 'A' server we publish to 'C' and 'D' servers. Now I wants to automate the script to capture the SAS dataset which published in 'B' server is available in all A,C and D servers. Have all SFTP connections from A to B and A to C and D.&lt;/DIV&gt;&lt;DIV&gt;Please suggest how to can we achieve on this. SAS datasets are in UNIX server.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Feb 2020 05:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624081#M183773</guid>
      <dc:creator>Banu</dc:creator>
      <dc:date>2020-02-12T05:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624083#M183774</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134610"&gt;@Banu&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;You have mentioned that you already publish from A server to C and D servers. Can't you use the same way to publish it from B to A,C,D?</description>
      <pubDate>Wed, 12 Feb 2020 05:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624083#M183774</guid>
      <dc:creator>AnandVyas</dc:creator>
      <dc:date>2020-02-12T05:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624088#M183777</link>
      <description>&lt;P&gt;Thanks for your reply. Here issue is not with copying through SFTP. I wants to show whether SAS dataset is published in all servers or not &amp;amp; Whether process it self published SAS dataset in same server or not &amp;amp; If process published SAS dataset, whether it published in Remote servers or not for this month. Needs generate report by showing all this info. Attached is the sample report. Please have a look once. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 06:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624088#M183777</guid>
      <dc:creator>Banu</dc:creator>
      <dc:date>2020-02-12T06:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624090#M183779</link>
      <description>&lt;P&gt;Looking on the report I suggest you need:&lt;/P&gt;
&lt;P&gt;1) Define FILENAMEs to each file on each server.&lt;/P&gt;
&lt;P&gt;2) Use FILEEXIST sas function to check does the file exist&lt;/P&gt;
&lt;P&gt;3) create a macro to check existence of a file given filename and server name&lt;/P&gt;
&lt;P&gt;4) do a loop to check them all and append result to a reporting dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; finale create the report&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 07:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624090#M183779</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-02-12T07:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624091#M183780</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134610"&gt;@Banu&lt;/a&gt;&amp;nbsp; - Moving SAS data between SAS servers is a LOT easier if you have a SAS/CONNECT installed on all of them and USE PROC UPLOAD and DOWNLOAD. The SAS logs from these jobs then become the audit trails for your data transfers.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 07:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624091#M183780</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-02-12T07:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624100#M183782</link>
      <description>&lt;P&gt;So you want to test if a file (in your case a .sas7bdat file) exists on a remote server, and do this non-interactively.&lt;/P&gt;
&lt;P&gt;A possible command to do this is&lt;/P&gt;
&lt;PRE&gt;ssh servername.domain.com test -f '/complete_path/dataset.sas7bdat'&lt;/PRE&gt;
&lt;P&gt;The single quotes are there if you need to send something like $HOME to the remote server. The command will return a 0 if the file exists, and a 1 if not.&lt;/P&gt;
&lt;P&gt;So start with creating a dataset with host names and dataset names:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasets;
input servername :$100 dsname :$200;
datalines;
server_a /path/test1.sas7bdat
server_b /path/test1.sas7bdat
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can run a data step off that and record the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data results;
set datasets;
length command $200;
command = "ssh " !! strip(servername !! " test -f '" !! strip(dsname) !! "'";
result = system(command);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you're not sure what the command returns, use a dynamic pipe to get messages:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data results;
set datasets;
length command $200;
command = "ssh " !! strip(servername !! " test -f '" !! strip(dsname) !! "'; echo $?";
infile dummy pipe filevar=command truncover eof=done end=last;
start:
  input line $100.;
  if last then result = input(line,best.);
  output;
  go to start;
done:
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I got the hint with using a remote &lt;FONT face="courier new,courier"&gt;test&lt;/FONT&gt; through ssh from&amp;nbsp;&lt;A href="https://superuser.com/questions/850158/how-to-check-if-file-exists-in-remote-sftp-server-from-local-linux-script" target="_blank" rel="noopener"&gt;https://superuser.com/questions/850158/how-to-check-if-file-exists-in-remote-sftp-server-from-local-linux-script&lt;/A&gt;, which was the first result of a Google search for "check existence of file with sftp".&lt;/P&gt;
&lt;P&gt;I tested the command from one of our AIX servers to another (both use openSSH), and it worked as described.&lt;/P&gt;
&lt;P&gt;You have to set up passwordless authentication with public/private key pairs to all servers first, or the ssh would always prompt for a password.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Edit: added capture of return code to the dynamic pipe.&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 08:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/624100#M183782</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-12T08:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Files capture through SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/625248#M184274</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134610"&gt;@Banu&lt;/a&gt;, since you accepted my suggestion as the solution, I am very interested in the actual solution you implemented.&lt;/P&gt;
&lt;P&gt;The reason for this is that the method I presented here is the final point of the paper I will present at #SASGF 2020 (Talking To Your Host). I would really like to include your solution as a "real world" example, including you in the acknowledgements and this thread as a reference.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 12:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-Files-capture-through-SAS-dataset/m-p/625248#M184274</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-17T12:48:24Z</dc:date>
    </item>
  </channel>
</rss>

