<?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: Sumif equavalent in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/478702#M123470</link>
    <description>Hi, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt; Thank you for your reply. I had figured out that the input data I was giving was incorrect.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 17 Jul 2018 16:14:27 GMT</pubDate>
    <dc:creator>hvempati</dc:creator>
    <dc:date>2018-07-17T16:14:27Z</dc:date>
    <item>
      <title>Sumif equavalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/477245#M122882</link>
      <description>&lt;P&gt;I have two tables&amp;nbsp;A and B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table A has Id, Item_Name, price_start_date, new_price_end_date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table B has Covers, Date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a code to add all the covers in Table A which lie in between Price_start_date and&amp;nbsp;&lt;SPAN&gt;new_price_end_date (that is sum&amp;nbsp;of covers between the dates in Table B).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I wrote a code to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Proc SQL;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;create table work.covers_before_total as&lt;BR /&gt;Select a.*, Sum(Case When a.Price_start_Date &amp;lt;= a.NEW_Price_End_Date and a.Price_start_Date &amp;lt;= b.date and a.NEW_Price_End_Date &amp;gt;= b.date then b.Covers Else 0 END) as covers&lt;BR /&gt;from work.covers_before a,work.covers_measurement_model b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;group by a.id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But the sum gives out 0 for some reason.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there also a better way of doing it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 20:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/477245#M122882</guid>
      <dc:creator>hvempati</dc:creator>
      <dc:date>2018-07-11T20:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sumif equavalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/477253#M122886</link>
      <description>&lt;P&gt;Your code (once modified to meet what proc sql expects) appears to work correctly. I ran:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
  create table work.covers_before_total as
    Select a.*, Sum(Case When a.Price_start_Date &amp;lt;= a.NEW_Price_End_Date and
                              a.Price_start_Date &amp;lt;= b.date and
                              a.NEW_Price_End_Date &amp;gt;= b.date then b.Covers Else 0 END) as covers
      from work.covers_before a,work.covers_measurement_model b
        group by a.id
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can't help further unless/until you provide some example data for the two datasets, and the result you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 21:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/477253#M122886</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-07-11T21:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sumif equavalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/478702#M123470</link>
      <description>Hi, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt; Thank you for your reply. I had figured out that the input data I was giving was incorrect.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2018 16:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sumif-equavalent-in-SAS/m-p/478702#M123470</guid>
      <dc:creator>hvempati</dc:creator>
      <dc:date>2018-07-17T16:14:27Z</dc:date>
    </item>
  </channel>
</rss>

