<?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 table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49618#M10301</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I have a macro that applies a DELETE * to several SAS tables, but the space in disk doesnt change, how can I really delete the records from the table, instead of marking them as deleted.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
    <pubDate>Wed, 14 Jul 2010 17:14:12 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-07-14T17:14:12Z</dc:date>
    <item>
      <title>Delete table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49618#M10301</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I have a macro that applies a DELETE * to several SAS tables, but the space in disk doesnt change, how can I really delete the records from the table, instead of marking them as deleted.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Wed, 14 Jul 2010 17:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49618#M10301</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-14T17:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Delete table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49619#M10302</link>
      <description>It would be helpful to know how you are deleting the observations. FSEDIT? IML?&lt;BR /&gt;
As a general rule observations marked for deletion are removed the next time the data set is reprocessed.  Such as with a PROC SORT.  In IML you can use the PURGE statement.</description>
      <pubDate>Wed, 14 Jul 2010 17:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49619#M10302</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-07-14T17:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49620#M10303</link>
      <description>the sql delete statement is good where the objective is conditional deletion subject to a where clause. DELETE * implies all rows, a bit like TRUNCATE. &lt;BR /&gt;
A SAS equivalent to TRUNCATE might work with this PROC DATASETS combination [pre]option _last_ = &lt;YOUR_LIB_AND_DATA_SET_NAME&gt; ;&lt;BR /&gt;
 &lt;BR /&gt;
%let your_lib = %scan( WORK.&amp;amp;syslast, -2, . ) ;&lt;BR /&gt;
%let your_mem = %scan(      &amp;amp;syslast, -1, . ) ;&lt;BR /&gt;
 &lt;BR /&gt;
proc datasets library= &amp;amp;your_lib  nolist ;&lt;BR /&gt;
  delete newTab / mtype= data ; * just in case it already exists ;&lt;BR /&gt;
  run ;&lt;BR /&gt;
 * now copy required structure to the new entry ;&lt;BR /&gt;
  append base=newtab data= &amp;amp;your_mem(obs=0) ;&lt;BR /&gt;
  run ;&lt;BR /&gt;
 * next remove old data ;&lt;BR /&gt;
  delete &amp;amp;your_mem / mtype= data ;&lt;BR /&gt;
  run ;&lt;BR /&gt;
 * finally rename temporary structure with original member name ;&lt;BR /&gt;
  change newtab=&amp;amp;your_mem ;&lt;BR /&gt;
  run ;&lt;BR /&gt;
quit ;[/pre]&lt;BR /&gt;
Append is used because it will copy all indexes and integrity constraint definitions as well as column definitions, and it uses "copy" when the base= table doesn't exist.&lt;/YOUR_LIB_AND_DATA_SET_NAME&gt;</description>
      <pubDate>Thu, 15 Jul 2010 15:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49620#M10303</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-07-15T15:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Delete table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49621#M10304</link>
      <description>Hi Peter&lt;BR /&gt;
&lt;BR /&gt;
Nice code which preserves all indexes and integrity constraints! &lt;BR /&gt;
This mimics something like a REORG statement in PROC DATASETS which I hope SAS R&amp;amp;D will give us one day.&lt;BR /&gt;
&lt;BR /&gt;
I've run into two minor issues while running your code over a sample dataset:&lt;BR /&gt;
1: %let your_lib = %scan( WORK.&amp;amp;syslast, -2, . ) ;&lt;BR /&gt;
    I believe this should be without the 'WORK.'&lt;BR /&gt;
&lt;BR /&gt;
2: append base=newtab data= &amp;amp;your_mem(obs=0) ;&lt;BR /&gt;
  'obs=0' results in deletion of all records, also the ones which are not marked as deleted.&lt;BR /&gt;
&lt;BR /&gt;
Else: Everything run like a charm.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Patrick</description>
      <pubDate>Fri, 16 Jul 2010 10:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49621#M10304</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-07-16T10:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49622#M10305</link>
      <description>Patrick&lt;BR /&gt;
re: . . obs=0&lt;BR /&gt;
I wasn't expecting to do a REORG for this poster. I assumed he wanted to truncate the table with DELETE * and release the deleted space - i.e. not just mark for deletion ...&lt;BR /&gt;
&amp;gt; I have a macro that applies a DELETE * to several SAS&lt;BR /&gt;
&amp;gt; tables, but the space in disk doesnt change, how can&lt;BR /&gt;
&amp;gt; I really delete the records from the table, instead&lt;BR /&gt;
&amp;gt; of marking them as deleted.&lt;BR /&gt;
Of course, you may be right that I misunderstood the objective.&lt;BR /&gt;
&lt;BR /&gt;
As to that trick with WORK.&lt;BR /&gt;
Should the syntax be embedded in a macro, I would expect the parameter passed to be a one or two level name. &lt;BR /&gt;
From that &amp;amp;name %scan( &amp;amp;name, -1, . ) always returns the memname, but %scan( &amp;amp;name, -2, . ) won't return the libname if &amp;amp;name is just a one-level name (implying the work library). Hence %scan( WORK.&amp;amp;name, -2, . ) should find WORK where there is no "." in &amp;amp;name.&lt;BR /&gt;
Of course, it might catch out my accustomed approach in development where I use the user option or lib-ref to catch all one-level names in a permanent dataset &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Fri, 16 Jul 2010 12:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-table/m-p/49622#M10305</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-07-16T12:05:13Z</dc:date>
    </item>
  </channel>
</rss>

