<?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 CASE WHEN issue in PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628347#M185652</link>
    <description>&lt;P&gt;I am compiling dollar totals and unit totals from a data set using PROC SQL.&amp;nbsp; The dollar totals are fine but the output totals for the units are all the same.&amp;nbsp; I've enclosed the code and the output file below.&amp;nbsp; As you can see, I have set conditions with the CASE WHEN statement for each stage and used count (for units) and sum (for dollars).&amp;nbsp; I don't know why I get the same total for each group.&amp;nbsp; I need a second set of eyes to look at what is wrong.&amp;nbsp; Any feedback is appreciated.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;sql&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; current_balances &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; datepart(date) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; date &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt; &lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;mmddyy8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, count(loan_id) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; accts &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt; &lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;count(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; loan_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; count_current_accts &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amount_due&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amt_current &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;dollar16.2&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;count(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; loan_id &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; count_1_5_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amount_due &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amt_1_5_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;dollar16.2&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;count(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;6&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; loan_id &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; count_6_10_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;6&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amount_due &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amt_6_10_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;dollar16.2&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;date&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;accts&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;count_current_accts&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;amt_current&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;count_1_5_DPD&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;amt_1_5_DPD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px 0px 10.66px;"&gt;&lt;FONT color="#000000" face="Calibri"&gt;2/27/20&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;95,538&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;95,538&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;$46,964.47&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;95,538&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;$97,741.06&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2020 21:09:14 GMT</pubDate>
    <dc:creator>greg6363</dc:creator>
    <dc:date>2020-02-28T21:09:14Z</dc:date>
    <item>
      <title>CASE WHEN issue in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628347#M185652</link>
      <description>&lt;P&gt;I am compiling dollar totals and unit totals from a data set using PROC SQL.&amp;nbsp; The dollar totals are fine but the output totals for the units are all the same.&amp;nbsp; I've enclosed the code and the output file below.&amp;nbsp; As you can see, I have set conditions with the CASE WHEN statement for each stage and used count (for units) and sum (for dollars).&amp;nbsp; I don't know why I get the same total for each group.&amp;nbsp; I need a second set of eyes to look at what is wrong.&amp;nbsp; Any feedback is appreciated.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;sql&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; current_balances &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; datepart(date) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; date &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt; &lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;mmddyy8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;, count(loan_id) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; accts &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt; &lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;count(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; loan_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; count_current_accts &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amount_due&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amt_current &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;dollar16.2&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;count(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; loan_id &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; count_1_5_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amount_due &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amt_1_5_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;dollar16.2&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;count(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;6&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; loan_id &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; count_6_10_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;comma8.&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;sum(case &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due ge &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;6&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; days_past_due le &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amount_due &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; end) &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; amt_6_10_DPD &lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;dollar16.2&lt;/SPAN&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; line-height: normal;"&gt;&lt;SPAN style="background: white; margin: 0px; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;date&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;accts&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;count_current_accts&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;amt_current&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;count_1_5_DPD&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;amt_1_5_DPD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px 0px 10.66px;"&gt;&lt;FONT color="#000000" face="Calibri"&gt;2/27/20&lt;SPAN style="margin: 0px;"&gt;&amp;nbsp; &lt;/SPAN&gt;95,538&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;95,538&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;$46,964.47&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;95,538&lt;SPAN style="margin: 0px;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;$97,741.06&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 21:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628347#M185652</guid>
      <dc:creator>greg6363</dc:creator>
      <dc:date>2020-02-28T21:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: CASE WHEN issue in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628351#M185654</link>
      <description>&lt;P&gt;The COUNT() function adds 1 if a number is present, and does not add one if the variable is missing. So whether the value of the variable is set to 0 or set to loan_id, these all add 1. Try setting the value to missing instead of setting it to zero.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 21:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628351#M185654</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-28T21:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: CASE WHEN issue in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628354#M185657</link>
      <description>It worked. Thanks so much.</description>
      <pubDate>Fri, 28 Feb 2020 21:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CASE-WHEN-issue-in-PROC-SQL/m-p/628354#M185657</guid>
      <dc:creator>greg6363</dc:creator>
      <dc:date>2020-02-28T21:25:07Z</dc:date>
    </item>
  </channel>
</rss>

