<?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 VS union in proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414337#M67497</link>
    <description>&lt;P&gt;I'have tried this query under SAS in the present case it's not the same result ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my departement of company a collabor say :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"If the field B is empty for several and not empty for other value you can use this , it's to replace the union".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I consider this opinion like false ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a different result ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Nov 2017 11:12:08 GMT</pubDate>
    <dc:creator>azertyuiop</dc:creator>
    <dc:date>2017-11-17T11:12:08Z</dc:date>
    <item>
      <title>coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414317#M67494</link>
      <description>&lt;P&gt;Hello , Good Morning ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In SAS if I use a proc sql with a UNION like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;create table mytable as

select field1 , field2 , field3
from mystarttable
where cats(field1,'-',field2) = /* condition */
and field2 is not null
union
select field1 , field2 , field3
from mystarttable
where cats(field1) = /* condition */
and field2 is null ;&lt;/PRE&gt;&lt;P&gt;And after I decide to use "coalesce" function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;create table mytable as

select field1 , field2 , field3
from mystarttable
where cats(field1,'-',coalesce(field2,' ') )= /* condition */ ;&lt;/PRE&gt;&lt;P&gt;For you the result it's the same or it's different ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 10:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414317#M67494</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-17T10:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414320#M67495</link>
      <description>&lt;P&gt;Try it.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 10:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414320#M67495</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-17T10:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414324#M67496</link>
      <description>&lt;P&gt;What is the question?&amp;nbsp; All I can see is you have added this:&lt;/P&gt;
&lt;PRE&gt;coalesce(field2,' ') &lt;/PRE&gt;
&lt;P&gt;Which is saying if field is present use this, but if it doesn't contain anything, use nothing.&amp;nbsp; I.e. if field2="" then "" else field.&lt;/P&gt;
&lt;P&gt;Adding this part makes no sense.&amp;nbsp; Remember in SAS a variable has a length, and the length is a set of boxes, '&amp;nbsp; ' doesn't mean anythiing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 10:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414324#M67496</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-17T10:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414337#M67497</link>
      <description>&lt;P&gt;I'have tried this query under SAS in the present case it's not the same result ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my departement of company a collabor say :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"If the field B is empty for several and not empty for other value you can use this , it's to replace the union".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I consider this opinion like false ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a different result ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 11:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414337#M67497</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-17T11:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414338#M67498</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165260"&gt;@azertyuiop&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;............&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found a different result ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Never underestimate the "experiment" part of the scientific method.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 11:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414338#M67498</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-17T11:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414339#M67499</link>
      <description>&lt;P&gt;In my case field2 can be empty or not empty in the same column .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For exemple at line 1 "field2" is empty and not empty in line 2 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's to separate two case of selection in program .&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 11:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414339#M67499</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-17T11:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414376#M67501</link>
      <description>&lt;P&gt;For example a set of data to test :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;field1;field2;field3&lt;BR /&gt;01;10;ID123456&lt;BR /&gt;01;11;ID123456&lt;BR /&gt;02;;ID123456&lt;BR /&gt;02;;ID123457&lt;BR /&gt;02;11;ID123457&lt;BR /&gt;02;11;ID123458&lt;BR /&gt;09;19;ID123459&lt;BR /&gt;09;;ID123459&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 14:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414376#M67501</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-17T14:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce VS union in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414465#M67506</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165260"&gt;@azertyuiop&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;For example a set of data to test :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;field1;field2;field3&lt;BR /&gt;01;10;ID123456&lt;BR /&gt;01;11;ID123456&lt;BR /&gt;02;;ID123456&lt;BR /&gt;02;;ID123457&lt;BR /&gt;02;11;ID123457&lt;BR /&gt;02;11;ID123458&lt;BR /&gt;09;19;ID123459&lt;BR /&gt;09;;ID123459&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Post example data as a data step. A lot of us are not going to write one to read example data because we may not create a data set that is the same. For instance we do not know if your actual field1 or field2 are character or numeric.&lt;/P&gt;
&lt;P&gt;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 {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 16:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/coalesce-VS-union-in-proc-sql/m-p/414465#M67506</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-17T16:30:22Z</dc:date>
    </item>
  </channel>
</rss>

