<?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 Sas query optimization in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823276#M35047</link>
    <description>&lt;P&gt;Dear Friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help. Unable to retrieve results as expected with below query.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table dashare.Push_aggregated_table as&lt;BR /&gt;select&lt;BR /&gt;c.product,&lt;BR /&gt;OFFERSTARTDATE as startdate format date11. ,&lt;BR /&gt;OFFERENDDATE as enddate format date11. ,&lt;BR /&gt;CAMPAIGNTYPE,&lt;BR /&gt;a.Impressions as Imp,&lt;BR /&gt;b.Clicks as Clicks&lt;BR /&gt;from (&lt;BR /&gt;select INSERTDATETIME,PID,count(distinct PID) as Impressions from IMPRESSIONS_DATA where substr(PID,18,10)='C000001934'&lt;BR /&gt;group by PID) a&lt;BR /&gt;left join&lt;BR /&gt;(&lt;BR /&gt;select INSERTDATETIME,PID,count(distinct PID) as Clicks from CLICKS_DATA where substr(PID,18,10)='C000001934'&lt;BR /&gt;group by PID,INSERTDATETIME&lt;BR /&gt;) b&lt;BR /&gt;on a.PID=b.pid&lt;BR /&gt;inner join&lt;BR /&gt;(select min(OFFERSTARTDATE) as OFFERSTARTDATE,max(OFFERENDDATE) as OFFERENDDATE,product,CAMPAIGNTYPE,TREATMENTCODE ,CAMPAIGNCODE from CONTACTHISTORY where CHANNEL = 'Push Notification'&lt;BR /&gt;group by CAMPAIGNCODE,TREATMENTCODE&lt;BR /&gt;) c&lt;BR /&gt;on substr(a.PID,18,10)=c.CAMPAIGNCODE and substr(a.PID,29,10)= c.TREATMENTCODE&lt;BR /&gt;group by product,a.PID;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jul 2022 11:31:00 GMT</pubDate>
    <dc:creator>SASUserRocks</dc:creator>
    <dc:date>2022-07-14T11:31:00Z</dc:date>
    <item>
      <title>Sas query optimization</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823276#M35047</link>
      <description>&lt;P&gt;Dear Friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help. Unable to retrieve results as expected with below query.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table dashare.Push_aggregated_table as&lt;BR /&gt;select&lt;BR /&gt;c.product,&lt;BR /&gt;OFFERSTARTDATE as startdate format date11. ,&lt;BR /&gt;OFFERENDDATE as enddate format date11. ,&lt;BR /&gt;CAMPAIGNTYPE,&lt;BR /&gt;a.Impressions as Imp,&lt;BR /&gt;b.Clicks as Clicks&lt;BR /&gt;from (&lt;BR /&gt;select INSERTDATETIME,PID,count(distinct PID) as Impressions from IMPRESSIONS_DATA where substr(PID,18,10)='C000001934'&lt;BR /&gt;group by PID) a&lt;BR /&gt;left join&lt;BR /&gt;(&lt;BR /&gt;select INSERTDATETIME,PID,count(distinct PID) as Clicks from CLICKS_DATA where substr(PID,18,10)='C000001934'&lt;BR /&gt;group by PID,INSERTDATETIME&lt;BR /&gt;) b&lt;BR /&gt;on a.PID=b.pid&lt;BR /&gt;inner join&lt;BR /&gt;(select min(OFFERSTARTDATE) as OFFERSTARTDATE,max(OFFERENDDATE) as OFFERENDDATE,product,CAMPAIGNTYPE,TREATMENTCODE ,CAMPAIGNCODE from CONTACTHISTORY where CHANNEL = 'Push Notification'&lt;BR /&gt;group by CAMPAIGNCODE,TREATMENTCODE&lt;BR /&gt;) c&lt;BR /&gt;on substr(a.PID,18,10)=c.CAMPAIGNCODE and substr(a.PID,29,10)= c.TREATMENTCODE&lt;BR /&gt;group by product,a.PID;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 11:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823276#M35047</guid>
      <dc:creator>SASUserRocks</dc:creator>
      <dc:date>2022-07-14T11:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sas query optimization</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823277#M35048</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286518"&gt;@SASUserRocks&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need some help. Unable to retrieve results as expected with below query.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Explain further. What happens? Is there an error message?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, show us the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; log for this PROC SQL.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 11:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823277#M35048</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-14T11:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sas query optimization</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823279#M35049</link>
      <description>&lt;P&gt;Hardly possible to help, because i don't know what the expected result is. So you need to explain further.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 12:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823279#M35049</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-07-14T12:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sas query optimization</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823356#M35070</link>
      <description>&lt;P&gt;Examples of the 3 data sets used, as data step code so we can recreate them and test your code.&lt;/P&gt;
&lt;P&gt;Then what the expected result should be for the provided example. (Implies make the sets small enough you know what the result should be).&lt;/P&gt;
&lt;P&gt;Possibly a description of exactly how the results aren't matching your expectations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 16:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823356#M35070</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-14T16:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sas query optimization</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823377#M35073</link>
      <description>&lt;P&gt;At first sight, the only thing suspicious to me in your query is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;select ...., PID, count(distinct PID) .... from .... group by PID&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you group by &lt;EM&gt;PID&lt;/EM&gt;, then &lt;EM&gt;count(distinct PID)&lt;/EM&gt; will be one, by definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that the first subquery will require remerging because you do not group by INSERTDATETIME. This will likely generate more records than you expect. Either remove INSERTDATETIME from the select list or add INSERTDATETIME to the group by clause.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 17:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sas-query-optimization/m-p/823377#M35073</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-07-14T17:23:56Z</dc:date>
    </item>
  </channel>
</rss>

