<?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 : replace the null value in case statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831402#M328523</link>
    <description>Hi Tom,&lt;BR /&gt;Sorry, I accepted the answer but the code still not work. When I put in «&amp;nbsp;when 0&amp;nbsp;»&lt;BR /&gt;I don’t have 01/01/1960 any more, I obtain only the points. I suppose that my case statement doesn’t work.</description>
    <pubDate>Thu, 01 Sep 2022 13:12:09 GMT</pubDate>
    <dc:creator>SASdevAnneMarie</dc:creator>
    <dc:date>2022-09-01T13:12:09Z</dc:date>
    <item>
      <title>Proc sql : replace the null value in case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831377#M328512</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to replace the . value using the case statement, but it doesn't work, I have the 01/01/1960 in the place of . value.&lt;/P&gt;
&lt;P&gt;My code is :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table Donnees as 
   select  c.cd_rga
         , b.is_support
         , c.lb_court
         , b.d_fin
         , a.mt_ea,
	      , sum(a.mt_ea) as total	
	from SUPPORT as a

   left join (select is_support,
    case d_fin when . then d_fin="31DEC2023"d else d_fin
             end as d_fin format ddmmyy10.
              from RGA
              group by is_support
              having 
              or max(b.d_fin) = b.d_fin)  as b
   on a.is_support = b.is_support

	left join RGPC as c 
   on b.is_rga=c.is_rga

	where a.s_type_support="OK"
	group by c.cd_rga
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 09:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831377#M328512</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-09-01T09:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql : replace the null value in case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831398#M328521</link>
      <description>&lt;P&gt;If you are seeing dates of 01JAN1960 then the value is ZERO and not missing (or NULL as SQL would call it).&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 12:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831398#M328521</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-01T12:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql : replace the null value in case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831402#M328523</link>
      <description>Hi Tom,&lt;BR /&gt;Sorry, I accepted the answer but the code still not work. When I put in «&amp;nbsp;when 0&amp;nbsp;»&lt;BR /&gt;I don’t have 01/01/1960 any more, I obtain only the points. I suppose that my case statement doesn’t work.</description>
      <pubDate>Thu, 01 Sep 2022 13:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831402#M328523</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-09-01T13:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql : replace the null value in case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831408#M328527</link>
      <description>&lt;P&gt;You should be able to debug yourself by executing the different parts in simpler queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are two obvious things:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case d_fin
  when . then d_fin="31DEC2023"d 
  else d_fin
end as d_fin format ddmmyy10.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will set the calculated D_FIN variable ZERO when it is missing because MISSING does not equal the last day of 2023 and SAS returns a ZERO when a boolean expression like your equality test is FALSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This HAVING clause looks suspect.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;having or max(b.d_fin) = b.d_fin&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;OR is binary operator, it needs TWO arguments and you have only given it one.&lt;/P&gt;
&lt;P&gt;What did you intend here?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 15:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831408#M328527</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-01T15:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql : replace the null value in case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831417#M328535</link>
      <description>I see :  then d_fin="31DEC2023"d is not correct, I must write then "31DEC2023"d and it's work.</description>
      <pubDate>Thu, 01 Sep 2022 15:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831417#M328535</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-09-01T15:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql : replace the null value in case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831420#M328538</link>
      <description>&lt;P&gt;Or just use the SQL function COALESCE() instead of CASE construct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is exactly the type of situation that function is designed for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;coalesce(d_fin,"31DEC2023"d)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Sep 2022 15:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-replace-the-null-value-in-case-statement/m-p/831420#M328538</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-01T15:30:11Z</dc:date>
    </item>
  </channel>
</rss>

