<?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/263618#M51599</link>
    <description>&lt;P&gt;Going back to your original code, would it not be as simple as this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if rule_nm = 'MATCHING + NO SCORE IMPACTING' and score_impacting='N' then grand_total + total;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Apr 2016 18:09:44 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-04-13T18:09:44Z</dc:date>
    <item>
      <title>Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263607#M51593</link>
      <description>&lt;P&gt;Hi. &amp;nbsp;I'm wondering if it's possible to sum all instances of the Total column with Score_Impacting = 'N' (see attached)? &amp;nbsp;Is there a built-in for this or how could I accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking maybe something like this???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if rule_nm = 'MATCHING + NO SCORE IMPACTING' then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;total = sum(total (where score_impacting='N'));&lt;BR /&gt;end;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12454i9FD5232DFFBB6A10/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;</description>
      <pubDate>Wed, 13 Apr 2016 17:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263607#M51593</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-13T17:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263610#M51594</link>
      <description>&lt;P&gt;No, it depends on how you want the final results and if you're in a reporting procedure or data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc means is one way, proc sql is another, and there are others. But we need more information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you don't need code, feel free to include pictures.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 17:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263610#M51594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-13T17:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263613#M51595</link>
      <description>Sorry, I'm attempting this inside a data step, but I'm open to the most logical solution if it's not in the data step. Thanks.</description>
      <pubDate>Wed, 13 Apr 2016 17:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263613#M51595</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-13T17:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263616#M51598</link>
      <description>I'm gonna attempt Proc SQL I think.</description>
      <pubDate>Wed, 13 Apr 2016 18:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263616#M51598</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-13T18:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263618#M51599</link>
      <description>&lt;P&gt;Going back to your original code, would it not be as simple as this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if rule_nm = 'MATCHING + NO SCORE IMPACTING' and score_impacting='N' then grand_total + total;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 18:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263618#M51599</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-13T18:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263621#M51600</link>
      <description>&lt;P&gt;Seems I'm hung up here. &amp;nbsp;The reference to &lt;STRONG&gt;sum(_:)&lt;/STRONG&gt; is my attempt to apply the sum() function to all my variables beginning with &lt;STRONG&gt;_&lt;/STRONG&gt;. For instance I may have variables:&lt;/P&gt;&lt;P&gt;_04_11_2016&lt;/P&gt;&lt;P&gt;_3_26_2016&lt;/P&gt;&lt;P&gt;etc.... &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is these variables are the product of a previous Proc Transpose and they will not be the same with each run of the program. &amp;nbsp;Is there a way to work around my issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;108  proc sql;
109  CREATE TABLE cal_sums AS
110  select sum(total) as total, sum(_:), sum(null)
                                      -
                                      22
                                      200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, ), *, **, +, ',', -, '.', /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?,
              AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^,
              ^=, |, ||, ~, ~=.

ERROR 200-322: The symbol is not recognized and will be ignored.

111  from FinalData
112  where rule_nm = 'MATCHING + NO SCORE IMPACTING'
113    and score_impacting='N';
114  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Apr 2016 18:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263621#M51600</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-13T18:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263629#M51601</link>
      <description>&lt;P&gt;OK, how about this way then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=FinalData sum;&lt;/P&gt;
&lt;P&gt;where rule_nm = 'MATCHING + NO SCORE IMPACTING' and score_impacting='N';&lt;/P&gt;
&lt;P&gt;var total _: null;&lt;/P&gt;
&lt;P&gt;output out=cal_sums (drop=_type_ _freq_) sum=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 18:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263629#M51601</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-13T18:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263633#M51602</link>
      <description>&lt;P&gt;Wow...that looks promising, but it seems to have dropped the Rule_nm and Rule_order variables. &amp;nbsp;Is there a way to carry these thru to Cal_Sums dataset?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 19:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263633#M51602</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-13T19:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263635#M51603</link>
      <description>&lt;P&gt;Do you want separate totals for each Rule_order?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 19:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263635#M51603</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-13T19:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263649#M51604</link>
      <description>SQL Sum (across observations) is not the same as the datastep sum function (sum of variables within single observation). Hence the error.</description>
      <pubDate>Wed, 13 Apr 2016 19:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Sum/m-p/263649#M51604</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-13T19:58:36Z</dc:date>
    </item>
  </channel>
</rss>

