<?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 obtain the create date of a file in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691481#M37309</link>
    <description>&lt;P&gt;Some filesystems used in Linux store a "birth time" (ext4 or btrfs come to mind), but that can be misleading, as it keeps the value the file was first written to the &lt;EM&gt;local&lt;/EM&gt; filesystem. A copy across filesystems can result in a situation where the btime is past the modification and access time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fact that the operating system that powers the world has worked fine for decades without a creation date shows the &lt;EM&gt;technical&lt;/EM&gt; irrelevance of such a timestamp, IMHO. If it is needed for the working of a certain application, that needs to be part of the file data, as what SAS does with their files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Always keep in mind that most updates of a SAS dataset (e.g. PROC SORT) create a completely new file on the filesystem, and such is true for other applications (if I'm not completely wrong in my thinking, a docx or xlsx has to be rewritten completely, being a zipped archive).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;if your goal is to get that timestamp for SAS data, you can get it with PROC CONTENTS or from DICTIONARY.TABLES/SASHELP.VTABLE.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2020 09:33:44 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-10-14T09:33:44Z</dc:date>
    <item>
      <title>how to obtain the create date of a file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691409#M37301</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried this function (&lt;A href="https://support.sas.com/kb/40/934.html)" target="_blank"&gt;https://support.sas.com/kb/40/934.html)&lt;/A&gt;&amp;nbsp;but it seems that we are not able to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;get the create date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the macro :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;/** Macro technique **/                                                                                                                 
%macro FileAttribs(filename);                                                                                                           
   %local rc fid fidc;                                                                                                                   
   %local Bytes CreateDT ModifyDT;                                                                                                       
   %let rc=%sysfunc(filename(onefile,&amp;amp;filename));                                                                                       
   %let fid=%sysfunc(fopen(&amp;amp;onefile));                                                                                                  
   %let Bytes=%sysfunc(finfo(&amp;amp;fid,File Size (bytes)));                                                                                  
   %let CreateDT=%qsysfunc(finfo(&amp;amp;fid,Create Time));                                                                                     
   %let ModifyDT=%qsysfunc(finfo(&amp;amp;fid,Last Modified));                                                                                   
   %let fidc=%sysfunc(fclose(&amp;amp;fid));                                                                                                    
   %let rc=%sysfunc(filename(onefile));                                                                                                 
   %put NOTE: File size of &amp;amp;filename is &amp;amp;Bytes bytes;                                                                                  
   %put NOTE- Created &amp;amp;CreateDT;                                                                                                       
   %put NOTE- Last modified &amp;amp;ModifyDT;                                                                                                 
%mend FileAttribs;                                                                                                                      
                                                                                                                                        
/** Just pass in the path and file name **/                                                                                             
%FileAttribs(c:\aaa.txt)                &lt;BR /&gt;&lt;BR /&gt;Does&amp;nbsp;someone&amp;nbsp;know&amp;nbsp;how&amp;nbsp;to&amp;nbsp;get&amp;nbsp;the&amp;nbsp;create&amp;nbsp;date&amp;nbsp;with&amp;nbsp;the&amp;nbsp;format&amp;nbsp;monyy7.&amp;nbsp;for&amp;nbsp;a&amp;nbsp;any&amp;nbsp;file&amp;nbsp;hosted&amp;nbsp;on&amp;nbsp;a&lt;BR /&gt;unix&amp;nbsp;server.&amp;nbsp;The&amp;nbsp;modified&amp;nbsp;date&amp;nbsp;and&amp;nbsp;the&amp;nbsp;size&amp;nbsp;works&amp;nbsp;well&amp;nbsp;but&amp;nbsp;nothing&amp;nbsp;show&amp;nbsp;up&amp;nbsp;for&amp;nbsp;the&amp;nbsp;create&amp;nbsp;time&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;alain&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, 13 Oct 2020 21:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691409#M37301</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2020-10-13T21:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to obtain the create date of a file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691411#M37302</link>
      <description>From that page: &lt;BR /&gt;The create date is not stored with a file on UNIX. Therefore, the CRDATE variable that is within the code on the Full Code tab is missing on UNIX.&lt;BR /&gt;&lt;BR /&gt;From a google search it seems to depend very much on the Unix flavour so I suspect you need to provide more details about your set up as well, specifically what type of unix and version.</description>
      <pubDate>Tue, 13 Oct 2020 21:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691411#M37302</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-13T21:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to obtain the create date of a file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691426#M37305</link>
      <description>&lt;P&gt;I might try something like this:&lt;/P&gt;
&lt;PRE&gt;data fileatt;
   length name $ 20 value $ 40;
   drop fid j infonum;
   fid=fopen("&amp;amp;filename.", "I");
   infonum=foptnum(fid);
   do j=1 to infonum;
      name=foptname(fid, j);
      value=finfo(fid, name);
      put 'File attribute' name 'has a value of ' value;
      output;
   end;
   fclose(fid);
run;&lt;/PRE&gt;
&lt;P&gt;The data set, assuming no errors, should have a list of all the options you can request from your file system. The filename would have to have a full path.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 22:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691426#M37305</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-13T22:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to obtain the create date of a file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691432#M37306</link>
      <description>&lt;P&gt;Here's a piece of code I've had for years, and about every six months I use it in a response on the communities.&lt;/P&gt;
&lt;P&gt;It's way over designed for what you want, it pulls in all of the files in a directory, and then for each file picks up all of the attributes, but you should be able to see the necessary bits.&lt;/P&gt;
&lt;P&gt;I just tried it, and it still works, but I have a Windows machine and no access to Unix. Give it a try. The only thing you should need to change is the directory on the first line.&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Set the directory name to scan */
%let DirectoryName = C:\directory;

data DatasetsInADirectory;

   keep DirectoryAndDataset;
   length DatasetName DirectoryAndDataset $1024 FileRef $8;

   /* Assign the fileref */
   call missing(FileRef); /* Blank, so SAS will assign a file name */
   rc1 = filename(FileRef, "&amp;amp;DirectoryName."); /* Associate the file name with the directory */
   if rc1 ^= 0 then
      abort;

   /* Open the directory for access by SAS */
   DirectoryID = dopen(FileRef);
   if DirectoryID = 0 then
      abort;

   /* Get the count of directories and datasets */
   MemberCount = dnum(DirectoryID);
   if MemberCount = 0 then
      abort;

   /* Get all of the entry names ... directories and datasets */
   do MemberIndex = 1 to MemberCount;
      DatasetName = dread(DirectoryID, MemberIndex);
      if missing(DatasetName) then
         abort;

      DirectoryAndDataset = cats("&amp;amp;DirectoryName.","/",DatasetName);
      output;
   end;

   /* Close the directory */
   rc2 = dclose(DirectoryID);
   if rc2 ^= 0 then
      abort;
run;

data Attributes;

   keep DirectoryAndDataset OptionName OptionVal;
   length EntryType $12 FileRef $8 OptionName $20 OptionVal $1024;

   set DatasetsInADirectory;

   /* Assign the fileref */
   call missing(FileRef); /* Blank, so SAS will assign a file name */
   rc1 = filename(FileRef, DirectoryAndDataset); /* Associate the file name with the dataset or directory */
   if rc1 ^= 0 then
      abort;

   /* Open the entry for access by SAS. If it is a directory, zero will be returned */
   EntryID = fopen(FileRef);

   /* Process the entries */
   if EntryID = 0
   then do;
      EntryType = "Directory";
      output;
   end;

   else do;
      /* Get the number of options for the dataset */
      OptNum  = foptnum(EntryID); 
      if OptNum = . then
         abort;

         EntryType = "Dataset";

         /* Get all of the options for the dataset */
         do OptCount = 1 to OptNum;
            OptionName = foptname(EntryID, OptCount);
            OptionVal = finfo(EntryID, OptionName);
            output;
         end;
      
      /* Close the directory */
      rc2 = fclose(EntryID);
      if rc2 ^= 0 then
         abort;

   end;

run;

proc sql;
drop table DatasetsInADirectory;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Oct 2020 00:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691432#M37306</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2020-10-14T00:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to obtain the create date of a file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691481#M37309</link>
      <description>&lt;P&gt;Some filesystems used in Linux store a "birth time" (ext4 or btrfs come to mind), but that can be misleading, as it keeps the value the file was first written to the &lt;EM&gt;local&lt;/EM&gt; filesystem. A copy across filesystems can result in a situation where the btime is past the modification and access time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fact that the operating system that powers the world has worked fine for decades without a creation date shows the &lt;EM&gt;technical&lt;/EM&gt; irrelevance of such a timestamp, IMHO. If it is needed for the working of a certain application, that needs to be part of the file data, as what SAS does with their files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Always keep in mind that most updates of a SAS dataset (e.g. PROC SORT) create a completely new file on the filesystem, and such is true for other applications (if I'm not completely wrong in my thinking, a docx or xlsx has to be rewritten completely, being a zipped archive).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;if your goal is to get that timestamp for SAS data, you can get it with PROC CONTENTS or from DICTIONARY.TABLES/SASHELP.VTABLE.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 09:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-obtain-the-create-date-of-a-file/m-p/691481#M37309</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-14T09:33:44Z</dc:date>
    </item>
  </channel>
</rss>

