<?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: Regarding UNIX command in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333352#M75088</link>
    <description>&lt;P&gt;I'd prefer to write the program so it can run in batch, and then use cron to run it every 10 minutes.&lt;/P&gt;
&lt;P&gt;For convenience you can create a shell script that handles the SAS execution, and use that in the crontab.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2017 12:33:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-02-16T12:33:19Z</dc:date>
    <item>
      <title>Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333319#M75080</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a requirement to find &amp;nbsp;if a particular file exists in the SAS Server using a SAS EG Program &amp;nbsp;which should have unix command and need to schedule the command using Cron Job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one give me a sample X commnad do &amp;nbsp;thid search ? Other than X Command do &amp;nbsp;we have any other base sas coding which can be used to search for a file in a particular loaction and if the file is found &amp;nbsp;open the file and read the content ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance!!!&lt;/P&gt;&lt;P&gt;Anumol Antony&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 09:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333319#M75080</guid>
      <dc:creator>Anumol</dc:creator>
      <dc:date>2017-02-16T09:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333320#M75081</link>
      <description>&lt;P&gt;What do you know about the file? Do you just have a name and need to search in a directory tree, or do you have an absolute path name to it?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 09:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333320#M75081</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-16T09:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333322#M75082</link>
      <description>&lt;P&gt;There are a bunch of SAS external file function that might suit your needs better. They might not a easy to use like a UNIX shell command, but then you'll be "all SAS" in your program.&lt;/P&gt;
&lt;P&gt;Another option is to use FILENAME PIPE.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 09:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333322#M75082</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-16T09:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333332#M75083</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That really depends on what you are searching and how you need to read that file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without much more detail than you are providing, you could&amp;nbsp;search the system from current directory using the system command FIND, then if found access the file and read contents using sas own IO functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a simple example bellow with not much error handling, but It might give an idea of how to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;&lt;BR /&gt;     infile 'find . -name "MYFILE.SAS"' pipe; * search for file;&lt;BR /&gt;     input;&lt;BR /&gt;     _RC=filename('INFILE',_INFILE_); * try to assign a fileref;&lt;BR /&gt;     if not _RC then do;&lt;BR /&gt;        _FID=fopen('INFILE'); * open file;&lt;BR /&gt;        do until (not _RC); * while there's anything to read;&lt;BR /&gt;           _RC=fread(_FID); * read to buffer;&lt;BR /&gt;           _RC=fget(_FID,_INFILE_,200); * retrieve from buffer;&lt;BR /&gt;           putlog _INFILE_; * show in log;&lt;BR /&gt;        end;&lt;BR /&gt;        _RC=fclose(_FID); * close the file;&lt;BR /&gt;     end;&lt;BR /&gt;     stop; * process only first found;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 10:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333332#M75083</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-02-16T10:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333336#M75085</link>
      <description>&lt;P&gt;It is not clear to me what are you looking for (maybe because my limitted english):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- are you lookig for a program using a spcific file ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; then search for FILENAME with the file name and path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- are you looking for a program that executes unix/linux (or any other OS) comand ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; then upcase(compress()) &amp;nbsp;the line and search for: &amp;nbsp;'X"' &amp;nbsp; or "X'" &amp;nbsp;or for 'CALLSYSTEM('&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need a code to search all programs in a path you can addapt next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let search_string = ..any text ..;
%let suffix = sas;
%let root=/folders/myshortcuts/My_Folders/;
filename finp ("&amp;amp;root.source/*.&amp;amp;suffix"); 

data results;
     length fname _filepath $200;
     infile finp filename = _filepath eov=_eov truncover;
     input a_line $200.;
     fname = _filepath;
     
     if _eov=1 then do;
       _n=0;
       _eov=0;
     end;
     _n+1;
     
     if find(a_line,"&amp;amp;search_string",'i')
     then output;
     keep _n a_line fname;
run;     
   
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 10:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333336#M75085</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-16T10:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333338#M75086</link>
      <description>&lt;P&gt;Thank you all for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be precise please find my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I have a control file ( in &amp;nbsp;CSV Format) in server folder &amp;nbsp; that will be placed as a result of the &amp;nbsp;camapign from SAS CI&lt;/P&gt;&lt;P&gt;2. I need to constalatly serach for the contraol file , if the contraol file is present I need to Open the file and read the file and capture &amp;nbsp;the details into a SAS Data Set.&lt;/P&gt;&lt;P&gt;3. This Program needs to be scheduled so that every 10 minutes this runs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have written the programe which finds the file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let folder=/sasdata/export_files;&lt;BR /&gt;/* Check for presence of a KNOWN Filr */&lt;BR /&gt;data _null_;&lt;BR /&gt;if fileexist("&amp;amp;folder./abc.csv") then&lt;BR /&gt;call symputx('file_found','1');&lt;BR /&gt;else&lt;BR /&gt;call symputx('file_found','0');&lt;BR /&gt;run;&lt;BR /&gt;%put FILE_Found = &amp;amp;file_found;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to write a contnuation of this program if FILE_FOUND = 1 the read the file. &amp;nbsp;After completing the file I need to Schedule this Program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two Option we have is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Write this SAS Program and Schedule&lt;/P&gt;&lt;P&gt;2. Write a UNIX program in SAS EG ( X Command ) and schedule the same as Cron Job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Coudl you please let me know how I can complete this and which option &amp;nbsp;suites here better?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !!&lt;/P&gt;&lt;P&gt;Anumol Antony&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 11:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333338#M75086</guid>
      <dc:creator>Anumol</dc:creator>
      <dc:date>2017-02-16T11:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333352#M75088</link>
      <description>&lt;P&gt;I'd prefer to write the program so it can run in batch, and then use cron to run it every 10 minutes.&lt;/P&gt;
&lt;P&gt;For convenience you can create a shell script that handles the SAS execution, and use that in the crontab.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 12:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333352#M75088</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-16T12:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333353#M75089</link>
      <description>&lt;P&gt;I'm not familiar with chrone but with other scheduler (Control-M).&lt;/P&gt;
&lt;P&gt;Anyhow you can do it in same job, Here is the sas program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check;
    %let folder=/sasdata/export_files;
       /* Check for presence of a KNOWN File */
     data _null_;
          if fileexist("&amp;amp;folder./abc.csv") then
             call symputx('SYSCC',0);
         else
             call symputx('SYSCC',1);
    run;
  
   %if &amp;amp;syscc = 0 %then %do;&lt;BR /&gt;        %include "  .. program to read the control file etc. ...";&lt;BR /&gt;   %end;&lt;BR /&gt;%mend check;&lt;BR /&gt;%check;
          &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 12:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333353#M75089</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-16T12:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding UNIX command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333682#M75239</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone give us pointesr in acheiving the requirement using X Commans in SAS EG. We need to write a program in SAS EG using X Commands which should read a file from a particular location and archive the files to another location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Anumol Antony&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 06:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-UNIX-command/m-p/333682#M75239</guid>
      <dc:creator>Anumol</dc:creator>
      <dc:date>2017-02-17T06:00:33Z</dc:date>
    </item>
  </channel>
</rss>

