<?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 get datasets' name and creation time?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792788#M254026</link>
    <description>&lt;P&gt;you should be my SAS coach.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2022 08:39:48 GMT</pubDate>
    <dc:creator>hellohere</dc:creator>
    <dc:date>2022-01-27T08:39:48Z</dc:date>
    <item>
      <title>How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792719#M254004</link>
      <description>&lt;P&gt;Using tons of macros to process gezillion data, datasets are created in middle which are to delete.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I plan to use a macro to do so. The macro need get the list of datasets, under work directory, and the creation time.&lt;/P&gt;
&lt;P&gt;Based to the creation time, between the macro run starting and ending time, to remove datasets created in middle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone can help? To get the list of datasets in work and their creation time?!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 00:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792719#M254004</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T00:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792720#M254005</link>
      <description>&lt;P&gt;Do you mean something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%local start_dt dslist;
%let start_dt = %sysfunc(datetime());

/* Make some datasets */
data class; set sashelp.class; run;

proc sql noprint;
select nliteral(memname) into :dslist separated by ' '
from dictionary.tables
where libname='WORK'
  and modate &amp;gt;= &amp;amp;start_dt
;
quit;

%if (&amp;amp;sqlobs) %then %do;
proc delete data=&amp;amp;dslist;
run;
%end;
%mend test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's try it.&amp;nbsp; First lets make a dataset we want to keep.&amp;nbsp; Then run it and see what datasets it decides to delete.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xyz;
 set sashelp.class;
run;

options mprint;
%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;1439  data xyz;
1440   set sashelp.class;
1441  run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.XYZ has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


1442
1443  options mprint;
1444  %test;
MPRINT(TEST):   data class;
MPRINT(TEST):   set sashelp.class;
MPRINT(TEST):   run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


MPRINT(TEST):   proc sql noprint;
MPRINT(TEST):   select nliteral(memname) into :dslist separated by ' ' from dictionary.tables where libname='WORK' and modate &amp;gt;=
1958847449.313 ;
NOTE: The execution of this query involves performing one or more Cartesian product joins that can not be optimized.
MPRINT(TEST):   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


MPRINT(TEST):   proc delete data=CLASS;
MPRINT(TEST):   run;

NOTE: Deleting WORK.CLASS (memtype=DATA).
NOTE: PROCEDURE DELETE used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 01:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792720#M254005</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-27T01:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792721#M254006</link>
      <description>&lt;P&gt;Query the table sashelp.vtable/dictionary.table.&lt;/P&gt;
&lt;P&gt;It has the data set names and creation date/times (memname is table name, crdate is creation date).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternate suggestion - create a library named "user" at the top of the library.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, when SAS sees that library, tables will default to that location instead of work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Delete entire library at end of macro. Done.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Using tons of macros to process gezillion data, datasets are created in middle which are to delete.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I plan to use a macro to do so. The macro need get the list of datasets, under work directory, and the creation time.&lt;/P&gt;
&lt;P&gt;Based to the creation time, between the macro run starting and ending time, to remove datasets created in middle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone can help? To get the list of datasets in work and their creation time?!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 01:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792721#M254006</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-27T01:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792722#M254007</link>
      <description>FYI - my actual solution to this problem is to use _ in front of any temp tables in my processes. Then at the end I can use a wildcard to delete all tables that start with _ prefix using proc datasets. &lt;BR /&gt;&lt;BR /&gt;proc datasets lib=work nodetails nolist;&lt;BR /&gt;delete _:;&lt;BR /&gt;run; quit;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2022 01:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792722#M254007</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-27T01:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792787#M254025</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792787#M254025</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T08:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792788#M254026</link>
      <description>&lt;P&gt;you should be my SAS coach.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/792788#M254026</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-27T08:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/799805#M314533</link>
      <description>your lines work well. Why proc delete is not?!

7836         proc delete data=_:;  run;
                               -
                               22
                               200

ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, -, '.'.

ERROR 200-322: The symbol is not recognized and will be ignored.</description>
      <pubDate>Thu, 03 Mar 2022 11:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/799805#M314533</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-03-03T11:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get datasets' name and creation time?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/799920#M314593</link>
      <description>&lt;P&gt;Read the documentation. What does it say under DATA for PROC DELETE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1469bsvzgd33jn0z4xecxmx2bgo.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1469bsvzgd33jn0z4xecxmx2bgo.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 17:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-datasets-name-and-creation-time/m-p/799920#M314593</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-03T17:13:48Z</dc:date>
    </item>
  </channel>
</rss>

