<?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 Error: Case When / Is Not Null in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537291#M147745</link>
    <description>&lt;P&gt;Not exactly an answer to your error, but related...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Investigate the COALESCE function.&amp;nbsp; Your code would change from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when aa1.bky_filing_dt is not null
then aa1.bky_filing_dt
else Min(aa1.Load_Date) end as sort&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT
...
,COALESCE(aa1.bky_filing_dt, MIN(aa1.Load_Date)) as sort
,...&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Feb 2019 03:15:23 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2019-02-21T03:15:23Z</dc:date>
    <item>
      <title>Proc Sql Error: Case When / Is Not Null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537283#M147738</link>
      <description>&lt;P&gt;Hi SAS community,&lt;/P&gt;&lt;P&gt;I'm working on some code and getting a weird error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My SAS Log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;aa1.bky_filing_dt,&lt;BR /&gt;57 aa1.bky_remvl_dt,&lt;BR /&gt;58 aa1.bky_chapter,&lt;BR /&gt;59 aa1.last_ansys_eff_date,&lt;BR /&gt;60 aa1.ESCROW_OVERAGE_SHORTAGE,&lt;BR /&gt;61&lt;BR /&gt;62 case when aa1.bky_filing_dt is not null&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, (, ), ',', '.', ANSIMISS, AS, CROSS, FULL, INNER, JOIN, LEFT,&lt;BR /&gt;NATURAL, NOMISS, RIGHT.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;63 then aa1.bky_filing_dt&lt;BR /&gt;64 else Min(aa1.Load_Date) end as sort,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My proc sql code includes this case when statement which seems to be generating the error.&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;aa1.loan_no,&lt;BR /&gt;min(aa1.load_date) as min_load_dt,&lt;BR /&gt;max(aa1.load_date) as max_load_dt,&lt;BR /&gt;aa1.unique_id,&lt;BR /&gt;aa1.bky_filing_dt,&lt;BR /&gt;aa1.bky_remvl_dt,&lt;BR /&gt;aa1.bky_chapter,&lt;BR /&gt;aa1.last_ansys_eff_date,&lt;BR /&gt;aa1.ESCROW_OVERAGE_SHORTAGE,&lt;/P&gt;&lt;P&gt;case when aa1.bky_filing_dt is not null&lt;BR /&gt;then aa1.bky_filing_dt&lt;BR /&gt;else Min(aa1.Load_Date) end as sort&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from table b as aa1; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm simply trying to create a column named 'sort' that will use bky_filing_dt if the column isn't null, or use aa1.load_date.&amp;nbsp; Why is SAS giving me this error?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any suggestions that will help.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 03:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537283#M147738</guid>
      <dc:creator>belboy</dc:creator>
      <dc:date>2019-02-21T03:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Error: Case When / Is Not Null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537289#M147743</link>
      <description>&lt;P&gt;&lt;SPAN&gt;from table b as aa1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;in the above which is alias?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if aa1 is alias then what is b?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 03:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537289#M147743</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-21T03:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Error: Case When / Is Not Null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537291#M147745</link>
      <description>&lt;P&gt;Not exactly an answer to your error, but related...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Investigate the COALESCE function.&amp;nbsp; Your code would change from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when aa1.bky_filing_dt is not null
then aa1.bky_filing_dt
else Min(aa1.Load_Date) end as sort&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT
...
,COALESCE(aa1.bky_filing_dt, MIN(aa1.Load_Date)) as sort
,...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 03:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537291#M147745</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-02-21T03:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Error: Case When / Is Not Null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537292#M147746</link>
      <description>Sorry. TableB as aa1 ##- Please type your reply above this line. No&lt;BR /&gt;attachments. -##</description>
      <pubDate>Thu, 21 Feb 2019 03:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537292#M147746</guid>
      <dc:creator>belboy</dc:creator>
      <dc:date>2019-02-21T03:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Error: Case When / Is Not Null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537306#M147754</link>
      <description>&lt;P&gt;That code looks correct. You might be stuck with some nonprinting character in your code. try removing a couple of lines and retyping them anew.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 04:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Error-Case-When-Is-Not-Null/m-p/537306#M147754</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-02-21T04:30:36Z</dc:date>
    </item>
  </channel>
</rss>

