<?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: Merge Versus SQL - Utilising Index in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77989#M288079</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a small subset of the master dataset.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The set statement has an POINT= option to use direct (and not sequential) access against the Master dataset. See &lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This feature will use the index you constructed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jan 2013 19:02:04 GMT</pubDate>
    <dc:creator>RobPatelsky</dc:creator>
    <dc:date>2013-01-17T19:02:04Z</dc:date>
    <item>
      <title>Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77982#M288072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im looking to understand why a merge statement is not utilising an index in a merge statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset (3300 obs) which has been sorted by key field "Account_ID" and then merging to master file (89382152 obs) which has index on Account_ID already created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Temp;&lt;/P&gt;&lt;P&gt;Merge Data1 (in=a)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Master (in=b);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by account_Id;&lt;/P&gt;&lt;P&gt;if a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The merge statement is taking rough 1 hour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then run an SQL statement :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Sql;&lt;/P&gt;&lt;P&gt;Create Table Temp as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from Data1 as a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; master as b&lt;/P&gt;&lt;P&gt;on a.account_id = b.account_id;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have included the options msglevel=I at the beginning of my code and only the SQL statement usilises the pre defined index.&amp;nbsp; Why doesnt merge utilise it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated in understanding why this occurs and potential resolution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 15:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77982#M288072</guid>
      <dc:creator>Doyleuk</dc:creator>
      <dc:date>2013-01-17T15:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77983#M288073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since it's just doesn't, ever.&lt;/P&gt;&lt;P&gt;Is there an isue of using SQL instead?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 16:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77983#M288073</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-17T16:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77984#M288074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="paragraph"&gt;&lt;A name="n0zsh2u8z1gczcn1foytpsgpbvat"&gt;&lt;/A&gt; &lt;/P&gt;&lt;P class="paragraph"&gt;A&amp;nbsp; BY statement does not use an index in these situations if &lt;A name="n1f7fad98jt8lxn1wlki2hazzz8p"&gt;&lt;/A&gt;the data file is physically stored in sorted order based on the variables specified in the BY statement.&lt;/P&gt;&lt;P class="paragraph"&gt;&lt;/P&gt;&lt;P class="paragraph"&gt;This is in the SAS documentation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 16:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77984#M288074</guid>
      <dc:creator>RobPatelsky</dc:creator>
      <dc:date>2013-01-17T16:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77985#M288075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you supply the link as I've tried searching and cannot find what I am looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any options that can be forced upon it to use an index.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77985#M288075</guid>
      <dc:creator>Doyleuk</dc:creator>
      <dc:date>2013-01-17T18:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77986#M288076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;The server administrators are not keen on us using SQL as the utility files that are built when using SQL can use quite a lot of resources.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to discuss furhter with them and find out how much is uses when using datasets which have indices.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77986#M288076</guid>
      <dc:creator>Doyleuk</dc:creator>
      <dc:date>2013-01-17T18:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77987#M288077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you can force MERGE to use the index, but why would you want to do that?&amp;nbsp; Your program will just take forever to run that way, and will produce the same result.&amp;nbsp; The default action is to check whether the data is sorted, and if it is then rely on the sorted order.&amp;nbsp; If it's not, then use the index.&amp;nbsp; Why would you want to change that behavior?&amp;nbsp; If you want to test, try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge Data1 (in=a)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Master (in=b sortedby=some_other_variable_in_master);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by account_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Retrieving an entire data set using an index will take a long time ... Ian Whitlock once wrote a related paper titled something like "Why Did This Code Take 24 Hours to Run?"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77987#M288077</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-01-17T18:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77988#M288078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Documentation link is &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n06cy7dznbx6gen1q9mat8de6rdq.htm"&gt;http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n06cy7dznbx6gen1q9mat8de6rdq.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is documented in&lt;/P&gt;&lt;H1 class="booktitle"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/H1&gt;&lt;P class="booktitle"&gt;&lt;/P&gt;&lt;P&gt;section is:&lt;/P&gt;&lt;H1 class="title"&gt;Understanding SAS Indexes &lt;/H1&gt;&lt;P class="title"&gt;towards the bottom of this section is &lt;/P&gt;&lt;H2 class="title"&gt;Using an Index for BY Processing&lt;/H2&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77988#M288078</guid>
      <dc:creator>RobPatelsky</dc:creator>
      <dc:date>2013-01-17T18:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77989#M288079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a small subset of the master dataset.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The set statement has an POINT= option to use direct (and not sequential) access against the Master dataset. See &lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This feature will use the index you constructed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 19:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77989#M288079</guid>
      <dc:creator>RobPatelsky</dc:creator>
      <dc:date>2013-01-17T19:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77990#M288080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the KEY= option to lookup in the master database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set data1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set master key=account_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if _error_ then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * no match found, might need to use call missing to clear variables retreived from MASTER ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; * Reset _ERROR_ to prevent notes in SAS log ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; _error_=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 20:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77990#M288080</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-17T20:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77991#M288081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I stand corrected by Tom - &lt;STRONG&gt;key&lt;/STRONG&gt; is the correct SET option to use.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 20:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77991#M288081</guid>
      <dc:creator>RobPatelsky</dc:creator>
      <dc:date>2013-01-17T20:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77992#M288082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many Thanks to all those who replied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom using the key option. This looks to be what I am after. However I notice using this it will only pull out the a single observation from the master table.&amp;nbsp; Is there a what to pull out multiple obs from this dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is an account_id with 5 obs in the master, Can I pull out all 5 obs and match that to the one observation from the data1 dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 14:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77992#M288082</guid>
      <dc:creator>Doyleuk</dc:creator>
      <dc:date>2013-01-24T14:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77993#M288083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well let's sort this out a bit. Indexes are mainly used for to purposes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Subseting (including join optimization)&lt;/LI&gt;&lt;LI&gt;Sorting&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Generally, sorting is NOT recommended for large tables, as stated by Astounding. It will indeed take very long time.&lt;/P&gt;&lt;P&gt;So, most merging/joining needs to in some way have the input tables sorted in some way.&lt;/P&gt;&lt;P&gt;SQL handles this by sorting chunks of the input data, and sometimes it the SQL planners can do this smart enough the whole tables doesn't need sorting. And in some cases indexes can help optimize choosing which chunks should be read.&lt;/P&gt;&lt;P&gt;So, you are likely to have te data sorted some time during the process, and SQL have a spill file for this. Can't see taht this is worse than a temporary sorted table in saswork, or a other SAS files swapped to saswork. You could minimize this spill file by increasing the MEMSIZE and SORTSIZE to utilize as much as possible of RAM (and minimizing the need for spilling/swapping data to disk).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About KEY=. It's intended use is to do a single record look-up. Maybe you can tweak this by some odd data step programming, but I shouldn't recommend it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 15:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77993#M288083</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-24T15:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77994#M288084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just put it in a DO loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; set data1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do until (_error_) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; background-color: #ffffff; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set master key=account_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not _error_ then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * no match found, might need to use call missing to clear variables retreived from MASTER ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; background-color: #ffffff; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; * Reset _ERROR_ to prevent notes in SAS log ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; _error_=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 15:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77994#M288084</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-24T15:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77995#M288085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It sounds like your original MERGE step gets you the right answer, but takes a while to run.&amp;nbsp; You are hoping that using an index would speed things up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that's an accurate picture of what you are trying to do, there are some possibilities that don't involve an index.&amp;nbsp; Answers to these questions would help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does Data1 ever contain multiple records for the same account_id?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is every account_id in Data1 guaranteed to appear in Master?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some approaches:&amp;nbsp; If account_id is character, what is its length?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is Master both sorted by account_id and has an index on account_id?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this sort of merge occur many times for the same version of Master?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on your answers, significant savings may be possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 17:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77995#M288085</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-01-24T17:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77996#M288086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Daniel,&lt;/P&gt;&lt;P&gt;As stated by Astounding, you can force a merge statement to use an index.&amp;nbsp; However, the merge statement always attempts to read every observation in each dataset.&amp;nbsp; As a rule of thumb, this takes about 5 times as long as a simple sequential read.&amp;nbsp; Consider the following:&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge Data1 (in=A)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Master (in=B sortedby=_null_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by account_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if not A;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Clearly, the value of account_id in Data1 is not used to determine which record(s) to read in Master.&amp;nbsp; It's just a sequential match/merge.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if you want to use the value of account_id in Data1 to determine which record(s) to read in Master, then Tom's answer is the correct solution.&amp;nbsp; Or, using SQL - you might try:&lt;/P&gt;&lt;P&gt;options fullstimer;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table temp as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select select A.*, B.*&amp;nbsp; /* better to explicitly list desired variables */&lt;/P&gt;&lt;P&gt;&amp;nbsp; from Data1 as A&lt;/P&gt;&lt;P&gt;&amp;nbsp; inner join Master(sortedby=_null_) as B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; on A.account_id eq B.account_id;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;to test whether the server administrators concerns about resources are valid.&amp;nbsp; (I doubt it.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 02:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77996#M288086</guid>
      <dc:creator>DaveBirch</dc:creator>
      <dc:date>2013-01-25T02:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Versus SQL - Utilising Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77997#M288087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If merge is the prefered solution, one suggestion could be to move your data to SPDE, which will sort the input data on the fly using multi-threading. May still use some resources, but would be faster than using sort using indexes at least.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 08:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Versus-SQL-Utilising-Index/m-p/77997#M288087</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-25T08:33:59Z</dc:date>
    </item>
  </channel>
</rss>

