<?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: Sum and Case Statement Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198490#M266597</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's no way to say what's 'correct' without having sample input/output data. They may syntactically correct, but be logically incorrect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This appears incorrect to me, you'd at least need an END.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt; pipeline_x_alco_pc + Completions_ytd * prepayment) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt; LTD,&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jul 2015 17:26:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-07-08T17:26:53Z</dc:date>
    <item>
      <title>Sum and Case Statement Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198487#M266594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following code but I cant get the logic to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variables names are correct and I think the code I have produce should show what im trying to achieve. If anyone can interpret that I would be grateful. I thin the first 2 are correct and maybe the 4th one but not 100%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;case &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Date_Term_Prod = Key_hedge &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Conversion_Rate_hedge &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; end &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Alco_pc,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;Case &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Product_Term_comps = Term_hedge_2 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Prepayment_rate_hedge_2 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; end &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; prepayment,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;case &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; alco_pc = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; sum(Pipeline_ytd, Pipeline_ytd*alco_pc) end &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; pipeline_x_alco_pc,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; pipeline_x_alco_pc + Completions_ytd * prepayment) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; LTD,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;case &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Product_end_date = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; sum(Weekly_movement_Allocs * prepayment) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; sum(Weekly_movement_Allocs * Alco_pc * prepayment) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; weekly_movement&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 16:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198487#M266594</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2015-07-08T16:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and Case Statement Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198488#M266595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Every expression seems &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;syntactically&lt;/SPAN&gt; correct, except the fourth one which contains an incomplete &lt;STRONG&gt;CASE&lt;/STRONG&gt; expression.&lt;/P&gt;&lt;P&gt;Are you aware that there are two kinds of SUM functions in your query? &lt;STRONG&gt;SUM(x, y)&lt;/STRONG&gt; simply returns &lt;EM&gt;x + y,&lt;/EM&gt; whereas &lt;STRONG&gt;SUM(x*y), ...&amp;nbsp; GROUP BY a&lt;/STRONG&gt; returns the sum of &lt;EM&gt;x*y&lt;/EM&gt; over every value of &lt;EM&gt;a&lt;/EM&gt;. The first one is a SAS datastep function and the second one is a SQL aggregate function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 16:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198488#M266595</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-07-08T16:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and Case Statement Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198489#M266596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No I wasn't aware of that, thank you. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 17:25:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198489#M266596</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2015-07-08T17:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and Case Statement Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198490#M266597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's no way to say what's 'correct' without having sample input/output data. They may syntactically correct, but be logically incorrect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This appears incorrect to me, you'd at least need an END.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt; pipeline_x_alco_pc + Completions_ytd * prepayment) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt; LTD,&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 17:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-and-Case-Statement-Help/m-p/198490#M266597</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-08T17:26:53Z</dc:date>
    </item>
  </channel>
</rss>

