<?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: Delete rows quickly from table containing 200 million observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426377#M105040</link>
    <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;No, they are currently not in the same structure. The history one has all customer attributes name,dob, address etc about 100 columns. the second table just tells me the customer numbers which have changed data in any of the 100 columns compared to the history.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is then processed&amp;nbsp;to mark old record as expired and set the new records as current for each customerno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Short answer the second one just has customerno and is indexed. I can get it in the same structure if it helps.&lt;/P&gt;&lt;P&gt;I don't want to create a new dataset ideally unless unavoidable. I am trying to avoid I/O but introduced heavy I/O with delete process &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2018 11:25:17 GMT</pubDate>
    <dc:creator>sriharivn</dc:creator>
    <dc:date>2018-01-10T11:25:17Z</dc:date>
    <item>
      <title>Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426370#M105035</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to delete rows from one table based on another table. The table from where I want to delete rows has about 200 million records and is growing everyday. This is a customer dimension mart which tracks changes on customer attributes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As part of the ETL process, I am deleting changed (current) records and appending changed&amp;amp; new records. The whole process is quick&amp;nbsp;except for the deletion process as its my query which I believe&amp;nbsp;may not be&amp;nbsp;optimized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do this currently :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;delete * from&amp;nbsp;customer_history where (select distinct customerno from x) and current_flag='Y';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Delete process takes more than 2 hours which defeats the purpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X has about 800,000 to 1 million customerno generally. X is indexed on customerno. History table is indexed on customer, current_flag and a composite one having both.History has about 200m records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand the process I run currently has to traverse through all 200m records and apply the filter as part of the delete process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can probably modify the ETL a bit to do this differently but before I do that I want to see if I am doing anything fundamentally wrong here?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any help is much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426370#M105035</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-10T11:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426373#M105038</link>
      <description>&lt;P&gt;What do&amp;nbsp;&lt;SPAN&gt;customer_history&amp;nbsp;and&amp;nbsp;x look like? How many columns are there and are they structured the same way?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426373#M105038</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-10T11:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426377#M105040</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;No, they are currently not in the same structure. The history one has all customer attributes name,dob, address etc about 100 columns. the second table just tells me the customer numbers which have changed data in any of the 100 columns compared to the history.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is then processed&amp;nbsp;to mark old record as expired and set the new records as current for each customerno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Short answer the second one just has customerno and is indexed. I can get it in the same structure if it helps.&lt;/P&gt;&lt;P&gt;I don't want to create a new dataset ideally unless unavoidable. I am trying to avoid I/O but introduced heavy I/O with delete process &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426377#M105040</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-10T11:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426391#M105045</link>
      <description>&lt;P&gt;I'd keep both tables sorted by customerno. X should be sorted with nodupkey.&lt;/P&gt;
&lt;P&gt;Then merge:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data customer_history_new;
merge
  customer_history (in=a)
  x (in=b keep=customerno)
;
by customerno;
if a;
if not b or current_flag ne 'Y';
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once that step is through, remove the old customer_history and rename the new one.&lt;/P&gt;
&lt;P&gt;Indexes are not helpful here in terms of performance because you deal with at least a large subset of both tables; in such cases the indexes just cause extra I/O and reduce performance overall. Indexes are only good when you need to select less than 10% (rule of thumb) of a dataset in a step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 12:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426391#M105045</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-10T12:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426410#M105049</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
run;
data class;
modify class;
if sex='F' then remove;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Be careful, the table class might got corrupted .&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 12:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426410#M105049</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-10T12:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426420#M105050</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did forget the basic idea about using indexes with subset of data. thanks for reminding me about it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I know you say index is an overhead in this case.&amp;nbsp;But because both datasets are indexed on customerno, can I get away without sorting these 2 tables and do this merge right away? I thought index(logically) is a variable sorted with no duplicate entries. so I would imagine i don't have to sort. Please confirm if this wrong for what i am trying to do.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 12:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426420#M105050</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-10T12:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426422#M105052</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes we have had corruption issues with the SCD load transformation in DI, so trying to move away from that to a simpler solution.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 13:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426422#M105052</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-10T13:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426427#M105053</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
run;


proc iml;
edit class;
delete all where(sex='F');
purge;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you have IML module .&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 13:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426427#M105053</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-10T13:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426428#M105054</link>
      <description>&lt;P&gt;The index will give you &lt;EM&gt;all&lt;/EM&gt; matching observations of a dataset, it does not do a nodupkey on its own. So you need to take care of that and forcibly remove all duplicates where they might cause harm.&lt;/P&gt;
&lt;P&gt;When dealing with large datasets, it's always an advantage to store them sorted by the column(s) primarily used for access.&lt;/P&gt;
&lt;P&gt;In your case that means that keeping everything ordered by customerno will be a real booster.&lt;/P&gt;
&lt;P&gt;This is the technique I use for all my datasets.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 13:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426428#M105054</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-10T13:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426442#M105062</link>
      <description>&lt;P&gt;The problem may be that the SQL does the following, exactly because you have an index on the history table:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Unique customer numbers are extracted from X. OK, takes very little time as X is small.&lt;/LI&gt;&lt;LI&gt;For each customer number in X, the corresponding record is looked up using the composite index. Would be the fastest method with just a few (or a few hundred) records, but not with a million (if the history table is not sorted by the index variables, the lookup would be jumping from one disk segment to another all the time, meaning that the whole table may be read from disk many times over).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;If you do things with a datastep, you can turn the process on its head, so that customer numbers are looked up in the small table instead, e.g.:&lt;/P&gt;&lt;PRE&gt;data customer_history;
  modify costumer_history;
  where current_flag='Y';
  set x(keep=customerno) key=customerno/unique;
  if _iorc_ then
    _error_=0; /* not found, reset _error_ to avoid error message */
  else 
    remove; /* delete the record from history */
run;&lt;/PRE&gt;&lt;P&gt;The idea is that the X table index&amp;nbsp;hopefully is small enough to fit completely in memory. An alternative is to load the X table to a hash table, which executes slightly faster than the SET with KEY=, but on the other hand takes time to load. As I assume that you are only deleting one record for each value in X,&amp;nbsp;I think the&amp;nbsp;solution shown above&amp;nbsp;is the fastest when X is already indexed.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 13:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426442#M105062</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-01-10T13:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426447#M105065</link>
      <description>&lt;P&gt;Depending on your available memory, you could avoid the join altogether by creating a lookup format from dataset X:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=x (keep=customerno)
  out=cntlin (rename=(customerno=start))
  nodupkey
;
by customerno;
run;

data cntlin;
set cntlin end=done;
fmtname = 'checkfmt';
type = 'C';
label = 'yes';
hlo = ' ';
output;
if done
then do;
  hlo = 'O';
  start = '**OTHER**';
  label = 'no';
  output;
end;

proc format library=work cntlin=cntlin;
run;

data customer_history_new;
set customer_history;
if current ne 'Y' or put(customer_no,$checkfmt.) = 'no';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426447#M105065</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-10T14:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426498#M105081</link>
      <description>&lt;P&gt;Thanks. I tried this , sorted x by customerno with nodupkey.&amp;nbsp;&lt;BR /&gt;The process ran for over an hour and I&amp;nbsp;had to kill it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 15:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426498#M105081</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-10T15:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426502#M105083</link>
      <description>&lt;P&gt;Thanks Kurt. One clarification on the last step.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want to keep all the old records for the customer (flag='N') and delete only the Ys in the history for the customers in X. I want to keep the Ys for the other records which are not present in X.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; customer_history_new&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; customer_history&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; current &lt;SPAN class="token operator"&gt;ne&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Y'&lt;/SPAN&gt; or &lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;customer_no&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;checkfmt&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'no'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess this will remove all the Ys in the history and give me only Ns and also remove the X customers.&lt;/P&gt;&lt;P&gt;Is my understanding right?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 15:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426502#M105083</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-10T15:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426787#M105192</link>
      <description>&lt;P&gt;Yes. The condition is a DeMorgan transformation of your delete condition.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 06:28:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426787#M105192</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-11T06:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426788#M105193</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65896"&gt;@Srihari&lt;/a&gt;_v_tcs_com wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. I tried this , sorted x by customerno with nodupkey.&amp;nbsp;&lt;BR /&gt;The process ran for over an hour and I&amp;nbsp;had to kill it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorting a dataset with 1 million records and one variable should be done in less than a minute on any reasonably current computer. There's something seriously amiss here.&lt;/P&gt;
&lt;P&gt;Do you work on networked drives?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 06:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/426788#M105193</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-11T06:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/427623#M105513</link>
      <description>&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this. The first time it ran for about 45 min and did the job. Re-ran it and it went into a state where nothing happened and I had to kill the session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this, I thought I will sort the big (200m) dataset and try your method.&lt;/P&gt;&lt;P&gt;Sorting took about 25 min (off-peak hours). Delete then took just 6 mins !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have checked this for multiple days and the behaviour is consistent.&lt;/P&gt;&lt;P&gt;I didn't know sorting a dataset would make that much of a difference !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now trying to figure out if I can sort this dataset quickly! I guess I'm being greedy now ? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to all of you&amp;nbsp;for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 09:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/427623#M105513</guid>
      <dc:creator>sriharivn</dc:creator>
      <dc:date>2018-01-15T09:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/427626#M105515</link>
      <description>&lt;P&gt;25 minutes is not a big thing for that kind of data. Balance it with the performance improvement you get.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to speed up the operation, first diagnose the process. Are your CPU's loaded to the brim while the sort is running, or do you have lots of I/O waits? I suspect the latter, in which case you need to start optimizing your storage.&lt;/P&gt;
&lt;P&gt;Get a clear picture of your storage infrastructure.&lt;/P&gt;
&lt;P&gt;Consider switching to SSD drives, and putting your logical volumes on stripesets of physical "disks", thereby spreading the physical load on several devices.&lt;/P&gt;
&lt;P&gt;Keep permanent storage, WORK and UTILLOC on separate volumes, and also make sure that they are physically separate (if they are not on a SAN, in which case you need to work with your SAN admins). Avoid working on a network share by all means.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're CPU-bound, get faster or more processors.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 09:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/427626#M105515</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-15T09:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows quickly from table containing 200 million observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/427916#M105592</link>
      <description>&lt;P&gt;1- Formats can be slow for large numbers of values in my experience.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- Keep in mind that a sorted table will be fast not only for maintenance for you as an admin, but also for all users.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3- Rewriting sorted tables is just a matter of copying the table, so if you have the space it should not take long&amp;nbsp;considering&amp;nbsp;the volume you have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4- If you are I/O bound, using SPDE with binary compression instead of the V9 engine is a must as it will typically decreases table size by 90%. This engine also processes indexes much faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5- When doing such updates, I like to keep tabs of what happens in the log and usually use something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data NEWHISTORY (drop=_:); 
  if LASTOBS then put _REPLACED= _ADDED= _KEPT=; 
  merge HISTORY (in=OLD)
        NEW     (in=NEW)
        end=LASTOBS;
  by CUSTOMERNO CURRENT_FLAG;
  if OLD and NEW then _REPLACED+1;
  else if OLD then    _KEPT    +1;
  else                _ADDED   +1;
run;

proc sort data=NEWHISTORY 
          out =HISTORY(index=( ... )) 
          presorted;
  by CUSTOMERNO CURRENT_FLAG ;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Add the deletion logic as you see fit for your data (like:&amp;nbsp; &lt;FONT face="courier new,courier"&gt;if DEL then&amp;nbsp;do; _DELETE+1; delete; end;&lt;/FONT&gt; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sort step is there just because SAS have been sitting on their hands and there is still no way to &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/create-a-VALIDATESORT-data-set-option-to-validate-the-sort-order/idi-p/288038" target="_self"&gt;set the SORT VALIDATED flag&lt;/A&gt; in the data step. PROC SORT just copies the table here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Index creation is fast on sorted tables.&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;
&lt;P&gt;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&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>Tue, 16 Jan 2018 05:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-quickly-from-table-containing-200-million/m-p/427916#M105592</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-01-16T05:09:34Z</dc:date>
    </item>
  </channel>
</rss>

