<?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: why my code is running very slow (Modify statement to update master dataset ) in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232476#M14588</link>
    <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;Thank you for your reply. I will test update statement also. I checked the article update and modify are doing same function.&lt;/P&gt;
&lt;P&gt;so is there any advantage using modify statement over update statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using Unix platform forgot to mentionin original question:&lt;/P&gt;</description>
    <pubDate>Fri, 30 Oct 2015 16:39:34 GMT</pubDate>
    <dc:creator>nbonda</dc:creator>
    <dc:date>2015-10-30T16:39:34Z</dc:date>
    <item>
      <title>why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232416#M14584</link>
      <description>&lt;P&gt;Hi have a master dataset, to update this master dataset with transaction dataset I am using following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;creating empty dataset (one time):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; create table ma.master&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&amp;nbsp; ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; informat=8. format=8. label="Iabel_invoiceid",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Created_DT num&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; informat=mdyampm. format=datetime20. label="create_dt",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COMMENTS char(100)&amp;nbsp; informat=100.&amp;nbsp; format=100. label="comments"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; );quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to update this master dataset with transaction dataset&amp;nbsp; every day, I using following code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ma.master;&lt;/P&gt;
&lt;P&gt;modify ma.master&amp;nbsp; tr.tras_data&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;IF _iorc_ eq 1230013 then&lt;/P&gt;
&lt;P&gt;OUTPUT;&lt;/P&gt;
&lt;P&gt;else do;&lt;/P&gt;
&lt;P&gt;REPLACE;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 85000 records first time and every day i will have 30000 records in transaction dataset.&lt;/P&gt;
&lt;P&gt;Its taking more than 2 hours to complete. Why its running slow Please suggest me if anything I need to modify my cody.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 12:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232416#M14584</guid>
      <dc:creator>nbonda</dc:creator>
      <dc:date>2015-10-30T12:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232423#M14585</link>
      <description>&lt;P&gt;Why do you have all the additional if statements checking some automatic variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF _iorc_ eq 1230013 then
OUTPUT;
else do;
REPLACE;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It should just be an update by certain variables. &amp;nbsp;You should perhaps read the manual section on updating datasets:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001304308.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001304308.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 13:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232423#M14585</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-30T13:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232430#M14586</link>
      <description>&lt;P&gt;"When you use a BY statement with the MODIFY statement, the DATA step uses dynamic WHERE processing to find observations in the master data set. Neither the master data set nor the transaction data set needs to be sorted. For large data sets, however, sorting the data before you modify it can enhance performance significantly."&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001772743.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001772743.htm&lt;/A&gt;&lt;BR /&gt;Where is your replace statement&lt;BR /&gt;&lt;BR /&gt;Optimizing the dynamic where processing. Think of trying indexes (random IO)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 14:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232430#M14586</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-10-30T14:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232455#M14587</link>
      <description>&lt;P&gt;For a table with only 85,000 observations it is not worth the headache to implement trying to modify the table in place.&lt;/P&gt;
&lt;P&gt;Just replace the table. &amp;nbsp;Look into using the regular old UPDATE statement for applying your transactions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ma.master;
  attrib ID length=8 label='Invoice ID';
  attrib Created_DT length=8 informat=mdyampm. format=datetime20. label='Datetime Created' ;
  attrib COMMENTS length=$100 label='Invoice Comments';
  stop;
  call missing(of _all_);
run;

data ma.master;
  update ma.master tr.tras_data ;
  by id;
run;
&lt;/CODE&gt;&lt;/PRE&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>Fri, 30 Oct 2015 15:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232455#M14587</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-30T15:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232476#M14588</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;Thank you for your reply. I will test update statement also. I checked the article update and modify are doing same function.&lt;/P&gt;
&lt;P&gt;so is there any advantage using modify statement over update statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using Unix platform forgot to mentionin original question:&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 16:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232476#M14588</guid>
      <dc:creator>nbonda</dc:creator>
      <dc:date>2015-10-30T16:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232485#M14590</link>
      <description>&lt;P&gt;Hi jakarman,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I do&amp;nbsp; indexing on master table.&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 17:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232485#M14590</guid>
      <dc:creator>nbonda</dc:creator>
      <dc:date>2015-10-30T17:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232495#M14593</link>
      <description>&lt;P&gt;Updating in place is very usefull when:&lt;/P&gt;&lt;P&gt;a/ &amp;nbsp;having a big dataset and small number of updates&lt;BR /&gt;b/ Using it with SAS/share allowing views/updates form other places at the same moment&lt;BR /&gt;You can see the usage wiht Eguide / Base updating a dataset interactively.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The Creation of indexes can be done by:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/ on a existing dataset using "proc datasets"&lt;BR /&gt;&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n0mfav25learpan1lerk79jsp30n.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n0mfav25learpan1lerk79jsp30n.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;You can even define contraints and a audit dataset.&lt;/P&gt;&lt;P&gt;2/ as a datasetoption creating the dataset&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ledsoptsref/68025/HTML/default/viewer.htm#n1aaucjme18e43n1jfgz8zsijv88.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/ledsoptsref/68025/HTML/default/viewer.htm#n1aaucjme18e43n1jfgz8zsijv88.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Sometimes is is better to remove all options and tor recreate them after having refilled all records.&lt;BR /&gt;Adding records on existing dataset wiht indexes will require all updates in the index on each record.&lt;BR /&gt;&lt;BR /&gt;Performance on processing is knowing/understanding what will happen inside the egine room&lt;BR /&gt;(*typos... corrected)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 16:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232495#M14593</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-11-01T16:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232629#M14601</link>
      <description>&lt;P&gt;Sort the data sets and use a data step with UPDATE. Then check the performance. With these small record counts, the operation should be finished in seconds.&lt;/P&gt;
&lt;P&gt;What you run into is the fact that without sorting, the step scans all records of the master data set for every record of the update data set, basically causing 85K * 30K I/O operations.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 11:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232629#M14601</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-11-01T11:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232636#M14602</link>
      <description>&lt;P&gt;The advantages of modify include much more flexiblity and the ability to modify a data set in place.&lt;/P&gt;
&lt;P&gt;Of course those are also the disadvantages since the flexibility makes it more complex to understand and modifying a dataset in place is also a more complex operation and potentially dangerous. &amp;nbsp;So only use MODIFY if you need to.&lt;/P&gt;
&lt;P&gt;Note also that UPDATE is very strange tool and you need to understand how it works. The intent is to allow you to make changes just to specified variables. &amp;nbsp;So only the non missing values in the transaction records cause changes in the master records. (To change a value to missing you need to use the special missing ._ in the transaction dataset). &amp;nbsp;If your intent in the transactions is to totally replace the master record then just use MERGE instead of UPDATE.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 12:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232636#M14602</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-11-01T12:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: why my code is running very slow (Modify statement to update master dataset )</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232648#M14603</link>
      <description>&lt;P&gt;Tom, The update approach&amp;nbsp;modify in place is not weird. In contrary it is the basic reason for the RDBMS and SQL standard approach.&lt;BR /&gt;The SAS specific way handling data using SAS&amp;nbsp;datasets in not commonly known and accepted. Using the PDV and automatic advancing is often bashed and asked to be replaced by SQL. Using the now buzzing words NO-SQL could help, but you are aksing fo a complete different mindset of somebody just starting to use SAS.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 16:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/why-my-code-is-running-very-slow-Modify-statement-to-update/m-p/232648#M14603</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-11-01T16:29:07Z</dc:date>
    </item>
  </channel>
</rss>

