<?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: proc sql WITH in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742308#M232165</link>
    <description>&lt;P&gt;Where is the "other data" coming from? If it is SAS data and your Oracle data is large, it would be more efficient to load your SAS data as an Oracle temporary table and continue to do all of your processing in Oracle.&lt;/P&gt;</description>
    <pubDate>Wed, 19 May 2021 01:17:41 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2021-05-19T01:17:41Z</dc:date>
    <item>
      <title>proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/740941#M231553</link>
      <description>&lt;P&gt;I have this query below that works in Oracle, however, needed to run in SAS proc sql to join with other data. Does anyone know how to convert this statement to work with proc sql? Also, if someone is familiar with this output, how come with the invoice date range set between April and May 2021, this query still pulls in ALL dates in the ouput?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;with pay_cte( vendor_id,invoice_id, pay_amt,pay_cnt ) as (&lt;BR /&gt;select vendor_id,invoice_id, pay_amt,count(*)&lt;BR /&gt;from ps_voucher&lt;BR /&gt;where invoice_dt between '01-Apr-2021' and '31-May-2021'&lt;BR /&gt;group by vendor_id,invoice_id, pay_amt&lt;BR /&gt;having count(*)&amp;gt;1)&lt;BR /&gt;select t.vendor_id, t.voucher_id,t.INVOICE_ID,t.gross_amt, t.INVOICE_DT&lt;BR /&gt;from ps_voucher t&lt;BR /&gt;join pay_cte p on t.vendor_id=p.vendor_id and t.invoice_id = p.invoice_id&lt;BR /&gt;and t.gross_amt=p.pay_amt&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 20:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/740941#M231553</guid>
      <dc:creator>Mchan890</dc:creator>
      <dc:date>2021-05-12T20:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/740943#M231554</link>
      <description>&lt;P&gt;I don't speak Oracle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does this do?&lt;/P&gt;
&lt;P&gt;with pay_cte( vendor_id,invoice_id, pay_amt,pay_cnt ) as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 20:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/740943#M231554</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-12T20:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/740966#M231560</link>
      <description>If you explain the logic someone can help with the code conversion. SAS has a lot of functionality that doesn't require Common Table Expression functionality but its easier if you explain what it's doing.</description>
      <pubDate>Wed, 12 May 2021 21:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/740966#M231560</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-12T21:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742255#M232139</link>
      <description>&lt;P&gt;the WITH statement in Oracle is looking for a similar match of (vendor_id, invoice_id, gross_amt) having more than 1 match for potential duplicates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logic is trying to identify potential match in the data for a set of criteria (vendor_id, invoice_id, gross_amt) ... another would be for (invoice_id, invoice_dt, gross_amt) for example&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 18:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742255#M232139</guid>
      <dc:creator>Mchan890</dc:creator>
      <dc:date>2021-05-18T18:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742275#M232148</link>
      <description>Since there's a join this isn't quite a duplicate situation in my head. Can you please illustrate the problem with some data as examples? If you cannot use your data please feel free to use data in the SASHELP library. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 May 2021 20:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742275#M232148</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-18T20:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742308#M232165</link>
      <description>&lt;P&gt;Where is the "other data" coming from? If it is SAS data and your Oracle data is large, it would be more efficient to load your SAS data as an Oracle temporary table and continue to do all of your processing in Oracle.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 01:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742308#M232165</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-19T01:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742312#M232166</link>
      <description>&lt;P&gt;1.SAS does not support the Oracle WITH Clause.&lt;/P&gt;
&lt;P&gt;2.If the code you have given is exactly the code you want to run, then the join is not needed. You are pulling the data from ps_voucher in both the WITH clause subquery and join. In fact the way the join is structured it pulls all the data fro ps_voucher. In order to get data for&amp;nbsp;invoice date range set between April and May 2021, the following query should suffice. Do make changes as needed. I don't have your data to test it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table pay_cte (drop=cnt) as
select vendor_id, voucher_id, INVOICE_ID, gross_amt, INVOICE_DT, count(*) as cnt
from ps_voucher
where invoice_dt between '01-Apr-2021' and '31-May-2021'
group by vendor_id,invoice_id, pay_amt
having count(*)&amp;gt;1 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 May 2021 01:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742312#M232166</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-19T01:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql WITH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742398#M232227</link>
      <description>&lt;P&gt;Something like this? Note that you should use the numeric value for the dates to get an accurate selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select t.vendor_id
       , t.voucher_id
       , t.INVOICE_ID
       , t.gross_amt
       , t.INVOICE_DT
  from ps_voucher t join
    (select vendor_id,invoice_id, pay_amt, count(*) as pay_cnt 
     from ps_voucher
     where invoice_dt between '01APR2021'd and '31MAY2021'd
     group by vendor_id, invoice_id, pay_amt
     having count(*)&amp;gt;1) p 
  on t.vendor_id = p.vendor_id
  and t.invoice_id = p.invoice_id
  and t.gross_amt=p.pay_amt
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 May 2021 13:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-WITH/m-p/742398#M232227</guid>
      <dc:creator>DaanDNR</dc:creator>
      <dc:date>2021-05-19T13:36:09Z</dc:date>
    </item>
  </channel>
</rss>

