<?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 files and modified date in a dateset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667407#M199850</link>
    <description>&lt;P&gt;Alternatively via data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set sashelp.vtable;
where  libname='ADAM' ;
keep modate memname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Jul 2020 11:26:52 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2020-07-07T11:26:52Z</dc:date>
    <item>
      <title>list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667403#M199848</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;trying to get list of files&amp;nbsp; and modified date in a dataset . list of files is working but not modified date.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myDir "/work" ;

data test (keep=filename modified);
	did=dopen("myDir") ;
	filecount=dnum(did) ;
	
	do i=1 to filecount ;
	fid = fopen('myDir');
		filename=dread(did,i) ;
		modified=finfo(fid,"Last Modified");
		put filename= ;
		output ;
			fid=fclose(fid);
	end ;
	rc=dclose(did) ;

run ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 11:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667403#M199848</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2020-07-07T11:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667404#M199849</link>
      <description>&lt;P&gt;please try dictionary.tables as below from libname , you will see column memname with list and modate with modified date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname adam '~path of datasets';

proc sql;
create table want as select * from dictionary.tables where libname='ADAM' ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 11:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667404#M199849</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-07T11:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667407#M199850</link>
      <description>&lt;P&gt;Alternatively via data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set sashelp.vtable;
where  libname='ADAM' ;
keep modate memname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jul 2020 11:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667407#M199850</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-07T11:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667409#M199852</link>
      <description>Hi Thanks for this.&lt;BR /&gt;but I am looking for list of all files(ex: text,csv,datset,etc ) and their modified date in a directory to read them into a dateset.</description>
      <pubDate>Tue, 07 Jul 2020 11:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667409#M199852</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2020-07-07T11:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667411#M199853</link>
      <description>&lt;P&gt;please try this code as well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test (keep=filename modified);
length fref $8;
     rc=filename(fref,"/work");
 if rc = 0 then do;
 did = dopen(fref);
 rc = filename(fref);
 end;
dnum = dnum(did);
do i = 1 to dnum;
filename = dread(did, i);/* If this entry is a file, then output. */
fid = mopen(did, filename);
modified=finfo(fid,'Last Modified');  
if fid &amp;gt; 0 then output;
end; 
rc = dclose(did);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jul 2020 11:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667411#M199853</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-07T11:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667413#M199855</link>
      <description>I just sent another code, which will provide the output you are expecting</description>
      <pubDate>Tue, 07 Jul 2020 11:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667413#M199855</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-07T11:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667416#M199857</link>
      <description>&lt;P&gt;Make your code well-behaving by cleaning up all references it creates:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test (keep=fname modified);
length fref $8;
if filename(fref,"/work") = 0
then do;
  did = dopen(fref);
  if did ne 0
  then do;
    dnum = dnum(did);
    do i = 1 to dnum;
      fname = dread(did, i);
      fid = mopen(did, fname);
      if fid ne 0
      then do;
        modified = finfo(fid,'Last Modified');  
        output;
        fid = dclose(fid);
      end;
    end;
    did = dclose(did);
  end;
  rc = filename(fref);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as otherwise it will have "memory leaks" by accruing file references and file handles.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 11:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667416#M199857</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-07T11:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667432#M199864</link>
      <description>&lt;P&gt;Actually, I do not think "cleaning up" is strictly necessary in a data step. It seems that SAS takes case of cleaning up when the data step ends. For instance:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         filename x "%sysfunc(pathname(WORK))";
 74         
 75         data _null_;
 76           did=dopen('x');
 77           put _ALL_;
 78         run;
 
 did=1 _ERROR_=0 _N_=1
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 79         
 80         data _null_;
 81           did=dopen('x');
 82           put _ALL_;
 83         run;
 
 did=1 _ERROR_=0 _N_=1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So what we see is that the directory handle number (DID=1) get reused in the second step, because it becomes deallocated as the data step ends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In macros, om the other hand, and probably also in SAS/SCL programming, cleanup is not automatic, and is good practice.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 13:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667432#M199864</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-07-07T13:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667439#M199865</link>
      <description>&lt;P&gt;Yes, but ...&lt;/P&gt;
&lt;P&gt;On UNIX systems it is standard to set the number of available file handles for a user to something like 2000 per default, and that can quickly be used in a step that works through a "industrially populated" directory. Or once one starts to work with code that reads multiple directories in one step.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 13:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667439#M199865</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-07T13:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: list of files and modified date in a dateset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667553#M199926</link>
      <description>&lt;P&gt;Yes, of course! You can hit the ceiling in a single datastep if you do not close the handles. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 19:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/list-of-files-and-modified-date-in-a-dateset/m-p/667553#M199926</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-07-07T19:52:57Z</dc:date>
    </item>
  </channel>
</rss>

