<?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: Simulate Proc sql nested query in Datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122445#M25120</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You' re right. But so far I am not aware of Hash merging. The problem is with the existing code is already there and I would just have to enhance it without changing the structure really. So, I was looking for options basically.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Jan 2013 02:46:48 GMT</pubDate>
    <dc:creator>bnarang</dc:creator>
    <dc:date>2013-01-30T02:46:48Z</dc:date>
    <item>
      <title>Simulate Proc sql nested query in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122442#M25117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we have two set of data let's say A and B. Both of them contains the list of ID. I would like to select list of accounts in A which are in B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do so, I can write sql query like this:&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;&amp;nbsp;&amp;nbsp; Select acct from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where acct in ( Select acc from B);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is now, I do have an existing sas script which I need to modify&amp;nbsp; where large number of nested conditions are specified in datasteps. How can I apply this condition in same Datastep.&lt;/P&gt;&lt;P&gt;1 possibility is to have all the list of accounts in B as in macro variable and can apply where acct in (&amp;amp;acc_list) but this will not suffice in my case since the number of accounts are in millions and macro variable value has some limitations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 07:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122442#M25117</guid>
      <dc:creator>bnarang</dc:creator>
      <dc:date>2013-01-11T07:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate Proc sql nested query in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122443#M25118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since I don't have access to your SAS script, I'm not sure if I will give you the best advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to mimic left joins in the data step (assuming tha ID in table B is unique), you can use MERGE BY-logic, combined with data set option IN=, like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge a(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;&amp;nbsp;&amp;nbsp; b(in=b);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by acc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a and b;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option could by to import the ID:s from b into a hash table. Probably better performance, but requires some more programming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A third option is to build a format on ID on b, with a specific label on "other", the us that in a where clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where put(acc,acc_fmt.) not = 'ACC does not exist';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case assumed ACC is numeric.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 08:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122443#M25118</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-11T08:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate Proc sql nested query in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122444#M25119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi bnarang,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure, what is u r request. If your request is select list of accounts from A and which are in B table. Please check this below..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table res from&lt;/P&gt;&lt;P&gt;(select A.acct from A,B where A.acct=B.acct);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 16:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122444#M25119</guid>
      <dc:creator>NagendraKumarK</dc:creator>
      <dc:date>2013-01-17T16:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate Proc sql nested query in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122445#M25120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You' re right. But so far I am not aware of Hash merging. The problem is with the existing code is already there and I would just have to enhance it without changing the structure really. So, I was looking for options basically.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2013 02:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122445#M25120</guid>
      <dc:creator>bnarang</dc:creator>
      <dc:date>2013-01-30T02:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate Proc sql nested query in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122446#M25121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bnarang,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What kind of nested conditions are specified in these datasteps that you want to include in your proc sql ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you might simply add them under the 'where' or 'having' clause, depending whether their scope is simple or aggregated data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Create Table temp as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Select acct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where acct in (Select acc from B where &lt;EM&gt;&amp;lt;condition on table B&amp;gt;&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and &lt;EM&gt;&amp;lt;condition on table A&amp;gt;&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Florent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2013 18:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-Proc-sql-nested-query-in-Datastep/m-p/122446#M25121</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2013-01-30T18:08:47Z</dc:date>
    </item>
  </channel>
</rss>

