<?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: sql query in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104011#M29076</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have missing data in T1?&amp;nbsp; The NE operator is very inefficient, so avoid it if you can.&amp;nbsp; Even if you have some missing data, it might be more efficient to do the selects without the WHERE clauses and then delete the missing data later.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Aug 2012 19:09:34 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2012-08-24T19:09:34Z</dc:date>
    <item>
      <title>sql query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104007#M29072</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;I am using below sql query to extract the results for my requirement. I am able to get the reslts, but its taking 2 mins time for 10 input records (table: Ext_cus) also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please some one help me extract the same results in any efficient way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Req: if macro variable '&amp;amp;reg_cnt is ne 0 then i have to extarct all the records from t1. else i have to extract the records by join with reg_list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro ext_final;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; create table work.ext_final as&lt;BR /&gt;select * from Ext_cus t1&lt;/P&gt;&lt;P&gt;where &lt;BR /&gt;%if &amp;amp;reg_cnt ne 0 %then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (t1.region_id ne ' ');&lt;BR /&gt;%else (t1.customer_group_cd in (select region_nm1 from reg_list where region_nm1 ne ' ')) or &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (t1.customer_id in (select region_nm2 from reg_list where region_nm2 ne ' '))&amp;nbsp;&amp;nbsp; or&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (t1.region_id in (select region_nm3 from reg_list where region_nm3 ne ' ')) ;&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;%mend;&lt;BR /&gt;%ext_final;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 16:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104007#M29072</guid>
      <dc:creator>sunilreddy</dc:creator>
      <dc:date>2012-08-24T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: sql query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104008#M29073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using a left join instead of a IN from the various tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104008#M29073</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-08-24T18:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: sql query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104009#M29074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using same table in Multiple IN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104009#M29074</guid>
      <dc:creator>sunilreddy</dc:creator>
      <dc:date>2012-08-24T18:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: sql query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104010#M29075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;doesn't matter.&amp;nbsp; the left join is generally more efficient as it can take advantage of indesing and the IN cannot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 19:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104010#M29075</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2012-08-24T19:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: sql query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104011#M29076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have missing data in T1?&amp;nbsp; The NE operator is very inefficient, so avoid it if you can.&amp;nbsp; Even if you have some missing data, it might be more efficient to do the selects without the WHERE clauses and then delete the missing data later.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 19:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104011#M29076</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2012-08-24T19:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: sql query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104012#M29077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;exactly so won't the table have to be read multiple times with the different conditions?&lt;/P&gt;&lt;P&gt;Try the left join and let me know how much time that takes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 20:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sql-query/m-p/104012#M29077</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-08-24T20:37:55Z</dc:date>
    </item>
  </channel>
</rss>

