<?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 empty datasets.... in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Delete-empty-datasets/m-p/49984#M13568</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a proc sql that joins two datasets. But if one of the datasets is empty (if the 1st one is empty, so will the 2nd one be), I don't want the Proc Sql to create a new table/dataset. Is there a way to put a condition to check if the data sets has any rows populated?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to delete empty datasets in a library before I 'set' them. Is there a way to delete only empty datasets from a library ?&lt;/P&gt;&lt;P&gt;(proc datasets deletes all or the ones specified...but I have to check which ones are empty before I delete them. This has to be an automated process)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Nov 2011 20:38:57 GMT</pubDate>
    <dc:creator>Xinxin</dc:creator>
    <dc:date>2011-11-17T20:38:57Z</dc:date>
    <item>
      <title>Delete empty datasets....</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Delete-empty-datasets/m-p/49984#M13568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a proc sql that joins two datasets. But if one of the datasets is empty (if the 1st one is empty, so will the 2nd one be), I don't want the Proc Sql to create a new table/dataset. Is there a way to put a condition to check if the data sets has any rows populated?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to delete empty datasets in a library before I 'set' them. Is there a way to delete only empty datasets from a library ?&lt;/P&gt;&lt;P&gt;(proc datasets deletes all or the ones specified...but I have to check which ones are empty before I delete them. This has to be an automated process)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2011 20:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Delete-empty-datasets/m-p/49984#M13568</guid>
      <dc:creator>Xinxin</dc:creator>
      <dc:date>2011-11-17T20:38:57Z</dc:date>
    </item>
    <item>
      <title>Delete empty datasets....</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Delete-empty-datasets/m-p/49985#M13569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can query metadata to determine the number of observations in a table.&amp;nbsp; You might want to watch out for deleted observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select nobs-delobs into :nobs from dictionary.tables where libname='WORK' and memname='ONE' ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are creating a macro then you can use a %IF to generate the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;nobs %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop table work.one ;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are not then you could generate the code into a macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let drop=;&lt;/P&gt;&lt;P&gt;select 'drop table ' || catx('.',libname,memname) into :drop separated by ';' &lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where nobs-delobs=0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and libname='WORK' and memname in ('ONE','TWO')&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;&amp;amp;drop;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2011 21:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Delete-empty-datasets/m-p/49985#M13569</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-11-17T21:26:00Z</dc:date>
    </item>
  </channel>
</rss>

