<?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: Proc SQL Case Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176819#M302327</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will be probably&amp;nbsp; more easy to apply a format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Aug 2014 10:00:14 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2014-08-27T10:00:14Z</dc:date>
    <item>
      <title>Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176817#M302325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need support with my case statement please. I have a calcualted field within the CASE statement but I can't seem to get it to work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my error message -&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;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,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, THEN, ^,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table work.dtv as&lt;/P&gt;&lt;P&gt;select &lt;BR /&gt;distinct month_date,&lt;BR /&gt;balance_outstanding as balance,&lt;BR /&gt;curr_index_val as val,&lt;BR /&gt;avg (curr_index_val) as avg_val,&lt;BR /&gt;round(balance/val,0.00001)&amp;nbsp; as dtv format percent8.2,&lt;BR /&gt;case &lt;BR /&gt;when calculated dtv &amp;lt;30 then 'Less than 30%'&lt;BR /&gt;when calcualted dtv =&amp;gt;30 and &amp;lt;50 then '30%-50%'&lt;BR /&gt;when calcualted dtv =&amp;gt;50 and &amp;lt;60 then '50%-60%'&lt;BR /&gt;when calculated dtv =&amp;gt;60 and &amp;lt;75 then '60%-75%'&lt;BR /&gt;when calculated dtv =&amp;gt;75 and &amp;lt;95 then '75%-95%'&lt;BR /&gt;when calculated dtv =&amp;gt;95 and &amp;lt;100 then '95%-100%'&lt;BR /&gt;else '100%+' end as avedtv &lt;/P&gt;&lt;P&gt;from &lt;BR /&gt;gbasel.baseljul14&lt;BR /&gt;where optimum_platform = 'Optimum'&lt;BR /&gt;and Arrears_lit_stage_code not in ('L4','L5','L6')&lt;/P&gt;&lt;P&gt;group by &lt;BR /&gt;month_date, avedtv;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 09:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176817#M302325</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2014-08-27T09:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176818#M302326</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;Am just thinking we have been over this code a few times before.&amp;nbsp; There is a syntax error in the when statements (calculated spelt incorrectly, you cannot do ranges just with an And like that):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when calcualted dtv =&amp;gt;30 and &amp;lt;50 then '30%-50%'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Change to: when CALCULATED 30 &amp;lt;= dtv &amp;lt; 50 then '30%-50%'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Or:&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; when CALCULATED dtv =&amp;gt;30 and CALCULATED dtv &amp;lt;50 then '30%-50%'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is easier to debug if you split your code out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 09:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176818#M302326</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-27T09:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176819#M302327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will be probably&amp;nbsp; more easy to apply a format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 10:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176819#M302327</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-08-27T10:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176820#M302328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im now getting this error message for the 2 options used above -&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when CALCULATED 30 &amp;lt;= dtv &amp;lt; 50 then '30%-50%' &lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;when CALCULATED dtv =&amp;gt;30 and CALCULATED dtv &amp;lt;50 then '30%-50%'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 10:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176820#M302328</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2014-08-27T10:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176821#M302329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, typo on my part, calculated should go before the variable.:&lt;/P&gt;&lt;P&gt;when 30 &amp;lt;= CALCULATED dtv &amp;lt; 50 then '30%-50%'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To note, you do not need both the options I provided.&amp;nbsp; They basically show slightly different syntax, choose one or the other.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 10:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176821#M302329</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-27T10:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176822#M302330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still can't get it to work as required, below is my output from th code used -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" summary="Page Layout" width="144"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" width="72"&gt;dtv&lt;/TD&gt;&lt;TD class="xl65" style="border-left: medium none;" width="72"&gt;avedtv&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;0.00%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;0.02%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;0.05%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;0.06%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;0.03%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;0.07%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;82.72%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;55.48%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;28.13%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;84.26%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;73.74%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="border-top: medium none;" width="72"&gt;77.35%&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;" width="72"&gt;100%+&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 10:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176822#M302330</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2014-08-27T10:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176823#M302331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, its defaulting out of the case.&amp;nbsp; I can't really test without test data, however looking at the code there are several areas of concern to me, for instance you use a variable balance and val in calculation for dtv, are these in the original dataset, as you have not put calculated before them.&amp;nbsp; I would again suggest that you need to break down what you are doing so that you can see each piece of the code coming together.&amp;nbsp; From the code now its not clear what variables are in the dataset, some may get created as empty etc.&amp;nbsp; Start by part one, getting your sums.&amp;nbsp; For instance, you are grouping by a variable which doesn't exist until after the resolution of a formula requiring the calculated variable.&amp;nbsp; So:&lt;/P&gt;&lt;P&gt;Step 1 - Decide what the groupings are in the data you have available.&lt;/P&gt;&lt;P&gt;Step 2 - Do your sums to create a new table.&lt;/P&gt;&lt;P&gt;Step 3 - Assign percentage grouping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps post some test data, and what you expect out at the end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 10:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-Statement/m-p/176823#M302331</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-27T10:50:41Z</dc:date>
    </item>
  </channel>
</rss>

