<?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: Write a code to drop all blank datasets in a library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360867#M274709</link>
    <description>&lt;P&gt;No need for a loop - &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;'s good idea of "select ... from dictionary.tables" can be accompanied by a second statement in the same proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mylib.one work.two;
  set sashelp.class;
  stop;
run;

proc sql noprint;
  select distinct catx('.',libname,memname) 
    into :droplist separated by ','
    from dictionary.tables
    where libname in ('WORK','MYLIB') and nlobs=0;

  drop table &amp;amp;droplist;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145349"&gt;@Ankur32&lt;/a&gt;'s description&amp;nbsp;in another forum suggests that&amp;nbsp;"blank dataset" does NOT mean nlobs=0, but rather a dataset in which nlobs may be &amp;gt; 0 but that all the variables are always missing.&amp;nbsp; Frankly I think "blank" should mean no rows of data.&amp;nbsp; But if the alternative meaning is used, then the "nlobs=0" criterion will not work.&amp;nbsp; One would have to scan all datasets in a library, to see which (among those with nlobs&amp;gt;0), if any, have only missing values.&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 18:12:01 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-05-23T18:12:01Z</dc:date>
    <item>
      <title>Write a code to drop all blank datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360799#M274705</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me to&amp;nbsp;Write a code "to drop all blank datasets in a library".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360799#M274705</guid>
      <dc:creator>Ankur32</dc:creator>
      <dc:date>2017-05-23T15:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Write a code to drop all blank datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360807#M274706</link>
      <description>&lt;P&gt;some like this should work. Change the libname as per your requirement.&amp;nbsp;check &amp;nbsp;%put &amp;amp;dsn values;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; memname &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; :dsn SEPARATED BY &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;','&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dictionary.tables&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; upcase(libname) =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'WORK'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; nlobs = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;dsn;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;abc&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(countc(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%superq&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(dsn), &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(,)))+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;drop table &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;Work.&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%superq&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(dsn),&amp;amp;i,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(','));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;abc&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360807#M274706</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-23T15:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Write a code to drop all blank datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360810#M274707</link>
      <description>&lt;P&gt;Thank you.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360810#M274707</guid>
      <dc:creator>Ankur32</dc:creator>
      <dc:date>2017-05-23T15:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Write a code to drop all blank datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360814#M274708</link>
      <description>&lt;P&gt;1) Why do you have many datasets in your libraries that are empty and you don't know what these are? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Assuming by empty you mean zero observations:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="YOURLIB" and nobs=0)) end=last;
  if _n_=1 then call execute('proc datasets library=yourlib; delete ');
  call execute(name);
  if last then call execute('; quit; run;');
run;&lt;/PRE&gt;
&lt;P&gt;Obviously replace the text yourlib with the library you are talking about. &amp;nbsp;Then benefit of the above method is that only one procedure - datasets - is created and run, the given macro code in the other post will create x number of proc sql steps.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360814#M274708</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-23T15:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Write a code to drop all blank datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360867#M274709</link>
      <description>&lt;P&gt;No need for a loop - &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;'s good idea of "select ... from dictionary.tables" can be accompanied by a second statement in the same proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mylib.one work.two;
  set sashelp.class;
  stop;
run;

proc sql noprint;
  select distinct catx('.',libname,memname) 
    into :droplist separated by ','
    from dictionary.tables
    where libname in ('WORK','MYLIB') and nlobs=0;

  drop table &amp;amp;droplist;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145349"&gt;@Ankur32&lt;/a&gt;'s description&amp;nbsp;in another forum suggests that&amp;nbsp;"blank dataset" does NOT mean nlobs=0, but rather a dataset in which nlobs may be &amp;gt; 0 but that all the variables are always missing.&amp;nbsp; Frankly I think "blank" should mean no rows of data.&amp;nbsp; But if the alternative meaning is used, then the "nlobs=0" criterion will not work.&amp;nbsp; One would have to scan all datasets in a library, to see which (among those with nlobs&amp;gt;0), if any, have only missing values.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 18:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-a-code-to-drop-all-blank-datasets-in-a-library/m-p/360867#M274709</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-23T18:12:01Z</dc:date>
    </item>
  </channel>
</rss>

