<?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: COALESCE statement in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897657#M354742</link>
    <description>&lt;P&gt;Are you sure the issue is the COALESCE() function call?&amp;nbsp; It seems to work fine for me&lt;/P&gt;
&lt;PRE&gt;570  proc sql;
571  create table test as select a.*,coalesce(a.height,a.weight) as NEWVAR
572  from sashelp.class a, sashelp.class b
573  where b.height=calculated newvar;
NOTE: Table WORK.TEST created, with 23 rows and 6 columns.
&lt;/PRE&gt;
&lt;P&gt;Your WHERE clause looks invalid since it has the binary operator AND with only one input. Either remove the AND or place some other binary expression before it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table date_naiss as 
select pers.D_NAISS
     , sousc.no_pol
     , coalesce(ctant.ctant_pere,ctant.contrac) as COAL
from dossier sousc
   , dossier2 ctant
   , personne pers 
where (1=1) 
  and sousc.contr = calculated COAL
  and ctant.pers = pers.pers
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 07 Oct 2023 02:59:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-10-07T02:59:00Z</dc:date>
    <item>
      <title>COALESCE statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897594#M354704</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 join conditionally the data : if &lt;CODE class=" language-sas"&gt;ctant.ctant_pere &lt;/CODE&gt; is doesn't missing I'm using this key, in other way I'm using&amp;nbsp;&lt;CODE class=" language-sas"&gt;ctant.contrac.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;But my code is doesn't work, could you tell me where is the problem, please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table date_naiss
		as select 
			pers.D_NAISS, sousc.no_pol, coalesce(ctant.ctant_pere,ctant.contrac) as COAL
		from dossier sousc, 
			dossier2 ctant, personne pers where 
			and sousc.contr = calculated COAL
			and ctant.pers = pers.pers;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 15:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897594#M354704</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-10-06T15:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: COALESCE statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897595#M354705</link>
      <description>&lt;P&gt;Are you getting an error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code is untested, but you can just move that COALESCE to the join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE date_naiss AS
SELECT
  pers.date_naiss
  , sousc.no_pol
  , COALESCE(ctant.ctant_pere, ctant.contrac) AS coal
FROM
  dossier sousc
  , dossier2 ctant
  , personne pers
WHERE
 sousc.countr = COALESCE(ctant.pere, ctant.contrac)
 AND ctant.pers = pers.pers
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Again, I think that works but I can't tell without data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd assume the calculated doesn't work in the join.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 15:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897595#M354705</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2023-10-06T15:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: COALESCE statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897601#M354708</link>
      <description>Thank you, I already tried it, but seems thant COALESCE statement doesn't work with join.</description>
      <pubDate>Fri, 06 Oct 2023 16:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897601#M354708</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-10-06T16:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: COALESCE statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897606#M354711</link>
      <description>&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the "&amp;lt;/&amp;gt;" to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "&amp;lt;/&amp;gt;" icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 16:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897606#M354711</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-06T16:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: COALESCE statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897657#M354742</link>
      <description>&lt;P&gt;Are you sure the issue is the COALESCE() function call?&amp;nbsp; It seems to work fine for me&lt;/P&gt;
&lt;PRE&gt;570  proc sql;
571  create table test as select a.*,coalesce(a.height,a.weight) as NEWVAR
572  from sashelp.class a, sashelp.class b
573  where b.height=calculated newvar;
NOTE: Table WORK.TEST created, with 23 rows and 6 columns.
&lt;/PRE&gt;
&lt;P&gt;Your WHERE clause looks invalid since it has the binary operator AND with only one input. Either remove the AND or place some other binary expression before it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table date_naiss as 
select pers.D_NAISS
     , sousc.no_pol
     , coalesce(ctant.ctant_pere,ctant.contrac) as COAL
from dossier sousc
   , dossier2 ctant
   , personne pers 
where (1=1) 
  and sousc.contr = calculated COAL
  and ctant.pers = pers.pers
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Oct 2023 02:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COALESCE-statement-in-proc-sql/m-p/897657#M354742</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-07T02:59:00Z</dc:date>
    </item>
  </channel>
</rss>

