<?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 efficiently delete tables  from a library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896276#M354144</link>
    <description>&lt;P&gt;Or, similar to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s example but with CALL EXECUTE, there is no limit on how many table names could be listed.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Sep 2023 15:32:13 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-09-28T15:32:13Z</dc:date>
    <item>
      <title>How to efficiently delete tables  from a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896272#M354140</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt; I have table pgpr_rowcnt which will store 100000s of coloumns like this. these are present in sasme library&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;relname &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rowcount&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3343_1341 0&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3343_1352 0&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3343_1537 0&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3513_1341 4&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3513_1352 5&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3513_1537 2&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3232_1537 2&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3232_1352 13300&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3232_1341 10640&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3343_1341 372&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3121_1352 19220&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3121_1537 7688&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3343_1537 186&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3343_1352 465&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3121_1341 15376&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3232_1537 0&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3513_1341 0&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3513_1352 0&lt;/DIV&gt;
&lt;DIV&gt;lcp_pgpr_3513_1537 0&lt;/DIV&gt;
&lt;DIV&gt;k__pgpr_3513_1234 0&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I Need to delete table having rowcount value as 0&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; proc sql noprint;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select relname into :del_tables separated by ' '&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from &amp;amp;table..pgpr_rowcnt&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; where rowcount =0 ;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; quit;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;%put _TRACE tables needs to be deleted &amp;amp;del_tables;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; /* deleting tables having zero rowcount */&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;proc datasets library = &amp;amp;table nolist nowarn memtype=(data view);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;delete &amp;amp;del_tables. ;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; This is working but since we know we have some limitation of length (max&amp;nbsp;&lt;STRONG&gt;65,534)&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to store value in macro . can anyone please help me is there any other way I can do same process.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Thanks!!!&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Sep 2023 15:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896272#M354140</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2023-09-28T15:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to efficiently delete tables  from a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896275#M354143</link>
      <description>&lt;P&gt;If the list is longer than can be stored in macro variable then generate code instead of a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set &amp;amp;table..pgpr_rowcnt end=eof;
  where rowcount =0 ;
  if _n_=1 then put 
  "proc datasets library = &amp;amp;table nolist nowarn memtype=(data view);"
/ "  delete " @
  ;
  put relname  @;
  if eof then put ';' / 'run;quit;' ;
run;
%include code / source2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2023 15:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896275#M354143</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-28T15:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to efficiently delete tables  from a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896276#M354144</link>
      <description>&lt;P&gt;Or, similar to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s example but with CALL EXECUTE, there is no limit on how many table names could be listed.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 15:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896276#M354144</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-28T15:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to efficiently delete tables  from a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896278#M354145</link>
      <description>&lt;P&gt;Tables (SAS data sets) from a library or variables from a data set?&lt;/P&gt;
&lt;P&gt;Lets see if you can clean up your description to be a bit clearer of what you have and what you want to do.&lt;/P&gt;
&lt;P&gt;You say" table pgpr_rowcnt which will store 100000s of coloumns" and then show an example of exactly 2 columns. So how do those 2 columns relate to Pgpr_rowcnt?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Call execute comes to mind, no macro variable involved.&lt;/P&gt;
&lt;PRE&gt;data _null_;
   set &amp;amp;table..pgpr_rowcnt end=Lastone;
   if _n_=1 then call execute("  proc datasets library = &amp;amp;table nolist nowarn memtype=(data view);");
   if rowcount= 0 then call execute('delete '||relname||';');
   if lastone then call execute ('run; quit;');
run;&lt;/PRE&gt;
&lt;P&gt;This in effect stacks the code for proc datasets into the execution queue.&lt;/P&gt;
&lt;P&gt;Or use similar syntax to write the text to a program file and use %include to call the created code. This has the advantage of you can review the created code for syntax problems and have a document of what was done to your data and when.&lt;/P&gt;
&lt;P&gt;Note: Proc Datasets uses QUIT to end the procedure because it supports run group processing and a single run might be followed by others, especially if used interactively.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 15:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896278#M354145</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-28T15:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to efficiently delete tables  from a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896283#M354147</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;

  set &amp;amp;table..pgpr_rowcnt end=eof;
  where rowcount =0 ;
  if _n_=1 then call execute(
  "proc datasets library = &amp;amp;table nolist nowarn memtype=(data view); delete ");
  call execute(relname);
  call execute (" ");

  if eof then call execute(";run;quit;");

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;CALL EXECUTE version (untested)&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 16:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-efficiently-delete-tables-from-a-library/m-p/896283#M354147</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-09-28T16:05:59Z</dc:date>
    </item>
  </channel>
</rss>

