<?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: Find when file was created and put the information in data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866503#M342209</link>
    <description>&lt;P&gt;This has been asked many times before, the search function will reveal code that will, most likely, just need some tweaks to work in your environment.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2023 10:57:15 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2023-03-27T10:57:15Z</dc:date>
    <item>
      <title>Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866454#M342177</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In specific path there are located many files with similar name.&lt;/P&gt;
&lt;P&gt;The only difference between the file names is the date on the file name.&lt;/P&gt;
&lt;P&gt;Let's say that there is a list of file name that I want to check when the file was created and put the information in a data set.&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;Let's say that I want to check it for the following files:&lt;/P&gt;
&lt;P&gt;"/usr/local/SAS//score/daily_files/9.1.3.Loans.20230224"&lt;BR /&gt;"/usr/local/SAS//score/daily_files/9.1.3.daily.20230225"&lt;BR /&gt;"/usr/local/SAS//score/daily_files/9.1.3.daily.20230226"&lt;/P&gt;
&lt;P&gt;The wanted data set will have 2 columns:&lt;/P&gt;
&lt;P&gt;File_name&lt;/P&gt;
&lt;P&gt;File_Date_Created&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 05:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866454#M342177</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-03-27T05:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866456#M342179</link>
      <description>&lt;P&gt;Do you want to extract the date from the filename or get the date shown in file explorer?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 05:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866456#M342179</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-03-27T05:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866472#M342193</link>
      <description>&lt;P&gt;No,&lt;/P&gt;
&lt;P&gt;I want to extract date from the date the file was created lastly&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1679905280245.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82081iDE2DD603C48D8F57/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1679905280245.png" alt="Ronein_0-1679905280245.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 08:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866472#M342193</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-03-27T08:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866477#M342197</link>
      <description>&lt;P&gt;Of course there are OS command to explore this information.&lt;/P&gt;
&lt;P&gt;If you want to do it from within SAS, take a look at FINFO&amp;nbsp; and related functions:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0cpuq4ew0dxipn1vtravlludjm7.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0cpuq4ew0dxipn1vtravlludjm7.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 08:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866477#M342197</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-03-27T08:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866481#M342200</link>
      <description>&lt;P&gt;Take a look at my WUSS presentation:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-User-Groups-Library/WUSS-Presentation-Talking-to-Your-Host/ta-p/838344" target="_blank" rel="noopener"&gt;Talking to Your Host&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 08:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866481#M342200</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-27T08:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866503#M342209</link>
      <description>&lt;P&gt;This has been asked many times before, the search function will reveal code that will, most likely, just need some tweaks to work in your environment.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 10:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866503#M342209</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-03-27T10:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find when file was created and put the information in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866534#M342216</link>
      <description>&lt;P&gt;You just need to ask the operating system.&amp;nbsp; If you have XCMD option turned on you can use a simple PIPE to read in the output of the operating system command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not then use the DOPEN(), DREAD(), and FINFO() functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a %DIRTREE() macro that should make it trivial:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/dirtree.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/dirtree.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Head of macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dirtree
/*---------------------------------------------------------------------------
Build dataset of files in directory tree(s)
----------------------------------------------------------------------------*/
(directory    /* Pipe delimited directory list (default=.) */
,out=dirtree  /* Output dataset name */
,maxdepth=120 /* Maximum tree depth */
);
/*---------------------------------------------------------------------------
Use SAS functions to gather list of files and directories

directory - Pipe delimited list of top level directories

out - Dataset to create
maxdepth - Maximum depth of subdirectories to query

Output dataset structure
--NAME-- Len  Format      Description
FILENAME $256             Name of file in directory
TYPE       $1             File or Directory? (F/D)
SIZE        8 COMMA20.    Filesize in bytes
DATE        4 YYMMDD10.   Date file last modified
TIME        4 TOD8.       Time of day file last modified
DEPTH       3             Tree depth
PATH     $256             Directory name

Size is not available for the directories.
LASTMOD timestamp is only available on Unix for directories.

Will not scan the subtree of a directory with a path that is
longer then 256 bytes. For such nodes TYPE will be set to L .

----------------------------------------------------------------------------*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2023 14:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-when-file-was-created-and-put-the-information-in-data-set/m-p/866534#M342216</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-27T14:41:44Z</dc:date>
    </item>
  </channel>
</rss>

