<?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 gives errors in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559034#M10225</link>
    <description>&lt;P&gt;For your examples you can just eliminate the ELSE clause and the resulting value will be missing without you having to know whether you want numeric or character missing.&amp;nbsp; You might get a note about the missing ELSE but it should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;,case when LN_REGULAT.ACTION_TAKEN in (3,7) then LN_REGULAT.ACTION_DATE 
 end 'DENIED_DATE' 
,case when LN_REGULAT.ACTION_TAKEN in (2,4,5,8) then LN_REGULAT.ACTION_DATE 
 end 'WITHDRAWN_DATE'&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 May 2019 15:55:35 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-05-15T15:55:35Z</dc:date>
    <item>
      <title>Proc SQL CASE statement gives errors</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559025#M10219</link>
      <description>&lt;P&gt;I 'm trying to do this&amp;nbsp;CASE statement&lt;/P&gt;&lt;P&gt;Case when LN_REGULAT.ACTION_TAKEN in ( 3, 7) then LN_REGULAT.ACTION_DATE else Null end 'DENIED_DATE' ,&lt;/P&gt;&lt;P&gt;70 Case when LN_REGULAT.ACTION_TAKEN in( 2, 4,5,8) then LN_REGULAT.ACTION_DATE else Null end 'WITHDRAWN_DATE'&lt;/P&gt;&lt;P&gt;, but I got an error message saying that&amp;nbsp; "&lt;FONT color="#ff0000"&gt;ERROR: The following columns were not found in the contributing tables: Null&lt;/FONT&gt; "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then changed Null to '.', I got this error : "&lt;FONT color="#ff0000"&gt;ERROR: Result of WHEN clause 2 is not the same data type as the preceding results&lt;/FONT&gt;."&lt;/P&gt;&lt;P&gt;If I was to connect to table &amp;nbsp;LN_REGULAT directly from the data source, this case statement works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if I create the table as (select * form connection......), and then run this case statement, it doesn't work.&lt;/P&gt;&lt;P&gt;Could you please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 15:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559025#M10219</guid>
      <dc:creator>MelissaN</dc:creator>
      <dc:date>2019-05-15T15:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL CASE statement gives errors</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559026#M10220</link>
      <description>SAS doesn't have a concept of NULL, instead replace it with quotation marks with nothing in between them, ie "".&lt;BR /&gt;You likely don't want quotes around your new name either. &lt;BR /&gt;&lt;BR /&gt;Case when LN_REGULAT.ACTION_TAKEN in ( 3, 7) then LN_REGULAT.ACTION_DATE else "" end as DENIED_DATE</description>
      <pubDate>Wed, 15 May 2019 15:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559026#M10220</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-15T15:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL CASE statement gives errors</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559031#M10223</link>
      <description>&lt;P&gt;Thanks for you response.&lt;/P&gt;&lt;P&gt;I got this error instead&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: Result of WHEN clause 2 is not the same data type as the preceding results.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;LN_REGULAT.ACTION_DATE is a datetime value&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 15:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559031#M10223</guid>
      <dc:creator>MelissaN</dc:creator>
      <dc:date>2019-05-15T15:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL CASE statement gives errors</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559032#M10224</link>
      <description>Ah, then the quotes should be a period instead.&lt;BR /&gt;&lt;BR /&gt;Case when LN_REGULAT.ACTION_TAKEN in ( 3, 7) then LN_REGULAT.ACTION_DATE else . end as DENIED_DATE</description>
      <pubDate>Wed, 15 May 2019 15:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559032#M10224</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-15T15:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL CASE statement gives errors</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559034#M10225</link>
      <description>&lt;P&gt;For your examples you can just eliminate the ELSE clause and the resulting value will be missing without you having to know whether you want numeric or character missing.&amp;nbsp; You might get a note about the missing ELSE but it should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;,case when LN_REGULAT.ACTION_TAKEN in (3,7) then LN_REGULAT.ACTION_DATE 
 end 'DENIED_DATE' 
,case when LN_REGULAT.ACTION_TAKEN in (2,4,5,8) then LN_REGULAT.ACTION_DATE 
 end 'WITHDRAWN_DATE'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 15:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559034#M10225</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T15:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL CASE statement gives errors</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559035#M10226</link>
      <description>&lt;P&gt;This also works as well. Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 15:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL-CASE-statement-gives-errors/m-p/559035#M10226</guid>
      <dc:creator>MelissaN</dc:creator>
      <dc:date>2019-05-15T15:59:30Z</dc:date>
    </item>
  </channel>
</rss>

