<?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: List of all files in a location + Filename in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/List-of-all-files-in-a-location-Filename/m-p/67735#M14679</link>
    <description>I use this little macro to determine the last modified date of the files in a path.  It may help.&lt;BR /&gt;
&lt;BR /&gt;
%macro LastFileModifiedDate(filename);&lt;BR /&gt;
%global  mod_date mod_time;&lt;BR /&gt;
filename foo pipe "dir &amp;amp;filename /t:w /a:-d";                                                                                               &lt;BR /&gt;
&lt;BR /&gt;
data _null_;                                                                                                                            &lt;BR /&gt;
&lt;BR /&gt;
  infile foo firstobs=6;                                                                                                                &lt;BR /&gt;
&lt;BR /&gt;
  input mod_date ?? : mmddyy8. mod_time ?? &amp;amp; time8.;                                                                                    &lt;BR /&gt;
&lt;BR /&gt;
  if mod_date eq . then stop;                                                                                                           &lt;BR /&gt;
&lt;BR /&gt;
  put mod_date= worddate. / mod_time= timeampm.;   &lt;BR /&gt;
  call symput("mod_date",mod_date); &lt;BR /&gt;
  call symput("mod_time",mod_time); &lt;BR /&gt;
run;&lt;BR /&gt;
%put %sysfunc(putn(&amp;amp;mod_date,date7.));&lt;BR /&gt;
%put %sysfunc(putn(&amp;amp;mod_time,time8.));&lt;BR /&gt;
&lt;BR /&gt;
%mend;&lt;BR /&gt;
%LastFileModifiedDate(c:\temp\License.txt);</description>
    <pubDate>Tue, 01 Feb 2011 16:50:37 GMT</pubDate>
    <dc:creator>CurtisMack</dc:creator>
    <dc:date>2011-02-01T16:50:37Z</dc:date>
    <item>
      <title>List of all files in a location + Filename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-of-all-files-in-a-location-Filename/m-p/67734#M14678</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Please help me with this:&lt;BR /&gt;
&lt;BR /&gt;
FILENAME prep FTP LIST CD="/env/prod"&lt;BR /&gt;
&lt;BR /&gt;
   HOST = "xxx.xx.xx"&lt;BR /&gt;
&lt;BR /&gt;
   USER = "abcdef" PASS="{sas001}234567ljX3J1bg==";&lt;BR /&gt;
&lt;BR /&gt;
   DATA  in_list_file;&lt;BR /&gt;
&lt;BR /&gt;
     INFILE prep MISSOVER;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT permission $10.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT code 3.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT owner $10.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT group $10.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT size 15.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT month $3.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT day 2.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT hour_year $5.;&lt;BR /&gt;
&lt;BR /&gt;
     FORMAT file $60.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT permission $10.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT code 3.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT owner $10.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT group $10.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT size 15.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT month $3.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT day 2.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT hour_year $5.;&lt;BR /&gt;
&lt;BR /&gt;
     INFORMAT file $60.;&lt;BR /&gt;
&lt;BR /&gt;
     INPUT  permission $&lt;BR /&gt;
&lt;BR /&gt;
            code&lt;BR /&gt;
&lt;BR /&gt;
            owner $&lt;BR /&gt;
&lt;BR /&gt;
            group $&lt;BR /&gt;
&lt;BR /&gt;
            size&lt;BR /&gt;
&lt;BR /&gt;
            month $&lt;BR /&gt;
&lt;BR /&gt;
            day&lt;BR /&gt;
&lt;BR /&gt;
            hour_year $&lt;BR /&gt;
&lt;BR /&gt;
            file $ &lt;BR /&gt;
&lt;BR /&gt;
            ;&lt;BR /&gt;
&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But now we want to remove the ftp path and make to run with out FTP&lt;BR /&gt;
&lt;BR /&gt;
so I changed as FILENAME prep LIST "/env/prod" ;&lt;BR /&gt;
&lt;BR /&gt;
But I got message as ERROR: Invalid file, "/env/prod".&lt;BR /&gt;
&lt;BR /&gt;
I have 3 .txt files (ABC, ABD, ABF) which has to taken into account.&lt;BR /&gt;
&lt;BR /&gt;
Please let me know how can I get list of all files in the location(/env/prod)  so that I can use the below&lt;BR /&gt;
macro later to find out if input files are empty or not.&lt;BR /&gt;
&lt;BR /&gt;
%MACRO CheckEmptyFile;&lt;BR /&gt;
&lt;BR /&gt;
    PROC SQL NOPRINT;&lt;BR /&gt;
&lt;BR /&gt;
       SELECT count(*) INTO :nn_obs FROM in_list_file WHERE file LIKE '%AB%' AND size = 0;&lt;BR /&gt;
&lt;BR /&gt;
    QUIT;&lt;BR /&gt;
&lt;BR /&gt;
     &lt;BR /&gt;
&lt;BR /&gt;
    %PUT *** &amp;amp;nn_obs ***;&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
    %IF &amp;amp;nn_obs &amp;gt; 0 %THEN %MailScript(Some SO input files are empty !!!);&lt;BR /&gt;
&lt;BR /&gt;
%MEND CheckEmptyFile;&lt;BR /&gt;
&lt;BR /&gt;
Please let me know how can I get list of all files in filename so that I can use the above&lt;BR /&gt;
macro .&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the help.</description>
      <pubDate>Tue, 01 Feb 2011 13:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-of-all-files-in-a-location-Filename/m-p/67734#M14678</guid>
      <dc:creator>SASACC</dc:creator>
      <dc:date>2011-02-01T13:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: List of all files in a location + Filename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-of-all-files-in-a-location-Filename/m-p/67735#M14679</link>
      <description>I use this little macro to determine the last modified date of the files in a path.  It may help.&lt;BR /&gt;
&lt;BR /&gt;
%macro LastFileModifiedDate(filename);&lt;BR /&gt;
%global  mod_date mod_time;&lt;BR /&gt;
filename foo pipe "dir &amp;amp;filename /t:w /a:-d";                                                                                               &lt;BR /&gt;
&lt;BR /&gt;
data _null_;                                                                                                                            &lt;BR /&gt;
&lt;BR /&gt;
  infile foo firstobs=6;                                                                                                                &lt;BR /&gt;
&lt;BR /&gt;
  input mod_date ?? : mmddyy8. mod_time ?? &amp;amp; time8.;                                                                                    &lt;BR /&gt;
&lt;BR /&gt;
  if mod_date eq . then stop;                                                                                                           &lt;BR /&gt;
&lt;BR /&gt;
  put mod_date= worddate. / mod_time= timeampm.;   &lt;BR /&gt;
  call symput("mod_date",mod_date); &lt;BR /&gt;
  call symput("mod_time",mod_time); &lt;BR /&gt;
run;&lt;BR /&gt;
%put %sysfunc(putn(&amp;amp;mod_date,date7.));&lt;BR /&gt;
%put %sysfunc(putn(&amp;amp;mod_time,time8.));&lt;BR /&gt;
&lt;BR /&gt;
%mend;&lt;BR /&gt;
%LastFileModifiedDate(c:\temp\License.txt);</description>
      <pubDate>Tue, 01 Feb 2011 16:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-of-all-files-in-a-location-Filename/m-p/67735#M14679</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2011-02-01T16:50:37Z</dc:date>
    </item>
  </channel>
</rss>

