<?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 delete all data sets in work library except of one data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652139#M195758</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Let's say that I have many data sets in work library (let's say 2000 data sets).&lt;/P&gt;
&lt;P&gt;I want to keep only one data set called tbl_aaa&amp;nbsp; and delete all other data sets.&lt;/P&gt;
&lt;P&gt;What is the way to tell SAS to delete all data sets in work library except of tbl_aaa?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jun 2020 05:55:49 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-06-01T05:55:49Z</dc:date>
    <item>
      <title>delete all data sets in work library except of one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652139#M195758</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Let's say that I have many data sets in work library (let's say 2000 data sets).&lt;/P&gt;
&lt;P&gt;I want to keep only one data set called tbl_aaa&amp;nbsp; and delete all other data sets.&lt;/P&gt;
&lt;P&gt;What is the way to tell SAS to delete all data sets in work library except of tbl_aaa?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 05:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652139#M195758</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-06-01T05:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: delete all data sets in work library except of one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652141#M195759</link>
      <description>&lt;P&gt;Copy the dataset to a different library (or create it there in the first place), and use proc datasets with the kill option on WORK.&lt;/P&gt;
&lt;P&gt;Or do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select cats('WORK.',memname) into :to_delete separated by ' '
from dictionary.tables
where libname = 'WORK' and memname ne 'TBL_AAA':
quit;

proc delete data=&amp;amp;to_delete.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Jun 2020 06:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652141#M195759</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-01T06:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: delete all data sets in work library except of one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652143#M195760</link>
      <description>&lt;P&gt;Alternatively you can use the proc datasets as below, but you need the macro variable to_delete from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; code and use it in proc datasets&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=work memtype=data;
delete &amp;amp;to_delete;
run;
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>Mon, 01 Jun 2020 06:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652143#M195760</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-01T06:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: delete all data sets in work library except of one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652148#M195765</link>
      <description>&lt;P&gt;Yet another (just for fun?) approach would be "building a shelter" &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a b c d e f;
  set sashelp.class;
run;

options dlcreatedir;
libname shelter "%sysfunc(pathname(WORK))/shelter";

data shelter.a;
  set a;
run;

/*
proc datasets kill lib=work noprint;
run;
*/

proc delete lib = work data = _all_;
run;

data a;
  set shelter.a;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 06:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652148#M195765</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-06-01T06:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: delete all data sets in work library except of one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652195#M195785</link>
      <description>Use SAVE statement in PROC DATASETS .&lt;BR /&gt;&lt;BR /&gt;proc datasets lib=work memtype=data  nodetails ;&lt;BR /&gt;save  tbl_aaa ;&lt;BR /&gt;quit;</description>
      <pubDate>Mon, 01 Jun 2020 11:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-all-data-sets-in-work-library-except-of-one-data-set/m-p/652195#M195785</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-01T11:06:32Z</dc:date>
    </item>
  </channel>
</rss>

