<?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 delete data in table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373141#M89261</link>
    <description>&lt;P&gt;Overwriting it would be the fastest.&lt;/P&gt;
&lt;P&gt;data TABLE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set TABLE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2017 03:54:58 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2017-07-05T03:54:58Z</dc:date>
    <item>
      <title>How to delete data in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373032#M89230</link>
      <description>&lt;P&gt;I have millions of rows of data in a table, how do I delete the data without deleting the tables&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 15:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373032#M89230</guid>
      <dc:creator>dassuz</dc:creator>
      <dc:date>2017-07-04T15:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete data in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373033#M89231</link>
      <description>&lt;P&gt;There are several methods, I don't off the top of my head know which will be best resourcewise:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  delete from HAVE
  where &amp;lt;condition&amp;gt;;
quit;

data want;
  set have;
  if &amp;lt;condition&amp;gt;;
run;

data want;
  set have;
  where &amp;lt;condition&amp;gt;;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jul 2017 15:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373033#M89231</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-04T15:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete data in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373141#M89261</link>
      <description>&lt;P&gt;Overwriting it would be the fastest.&lt;/P&gt;
&lt;P&gt;data TABLE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set TABLE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 03:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373141#M89261</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-05T03:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete data in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373196#M89278</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152343"&gt;@dassuz&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Assuming we're talking about tables stored as SAS files (SAS tables as opposed to database tables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use PROC SQL / DELETE or less commonly use a SAS Datastep Modify / Remove.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue with SAS tables:&lt;/P&gt;
&lt;P&gt;The records don't get physically removed but get just flagged as deleted. The deleted records still require all the storage space.&lt;/P&gt;
&lt;P&gt;You can see this when using Proc Contents.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do i=1 to 3;output;end;
run;

proc sql;
  delete from have where i&amp;gt;1
  ;
quit;

proc contents data=have;
run;quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10127i5BA6C40FBEE0071C/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.JPG" title="Capture.JPG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your permanent SAS dataset gets later on Inserts or Updates then the space of the deleted observations gets re-used as far as I understand things.&lt;/P&gt;
&lt;P&gt;IF your SAS dataset is also compressed then make sure that it has been created with option REUSE=YES or you'll never get rid of the deleted observations in regards of space usage.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#p1agtd57jq75oun1d5vnghr3s1q8.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#p1agtd57jq75oun1d5vnghr3s1q8.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given all these challenges it's actually often more efficient to just re-write the whole SAS table. ...But of course if you're only deleting a few records in a big table or you have also indices and/or constraints defined on the table then that's probably not what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;....and for all of the above reasons if it comes to production implementations and bigger data volumes then my preference is to store and maintain data in a database as there the DBMS deals with all this stuff.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 10:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-data-in-table/m-p/373196#M89278</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-07-05T10:08:51Z</dc:date>
    </item>
  </channel>
</rss>

