<?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: Conditional sum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650582#M195095</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;! Thanks for your help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2020 03:21:31 GMT</pubDate>
    <dc:creator>dapenDaniel</dc:creator>
    <dc:date>2020-05-26T03:21:31Z</dc:date>
    <item>
      <title>Conditional sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650579#M195092</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input firmid $ Year indicator value;
datalines;
1001 1991  1  2
1001 1991  0  3
1001 1991  0  4
1001 1991  1  5
1002 2005  1  11
1002 2005  1  10
1002 2006  0  13
1002 2006  1  14
1002 2007  1  20
1002 2007  1  5
1002 2007  0  3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to calculate the sum for indicator is 1 and sum for indicator is 0 by firmid, year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The expected output is below.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input firmid $ Year value1 value0;
datalines;
1001 1991  7  7
1002 2005  21  0
1002 2006  14  13
1002 2007  25  3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;What code do I need to use? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 03:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650579#M195092</guid>
      <dc:creator>dapenDaniel</dc:creator>
      <dc:date>2020-05-26T03:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650581#M195094</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
    firmId,
    year,
    sum(case when indicator=1 then value else 0 end) as value1,    
    sum(case when indicator=0 then value else 0 end) as value0
from have
group by firmId, year;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 May 2020 03:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650581#M195094</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-05-26T03:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650582#M195095</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;! Thanks for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 03:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-sum/m-p/650582#M195095</guid>
      <dc:creator>dapenDaniel</dc:creator>
      <dc:date>2020-05-26T03:21:31Z</dc:date>
    </item>
  </channel>
</rss>

