<?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 coalesce or case-when efficiency in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61643#M13389</link>
    <description>hi experts,&lt;BR /&gt;
&lt;BR /&gt;
i'd like to check a variable if it is null or missing. if so, i'll assign the value 0 to another column, else the other column will just take it's value.&lt;BR /&gt;
&lt;BR /&gt;
which between these two is more efficient?&lt;BR /&gt;
&lt;BR /&gt;
case when var1 not is missing then var1 else 0 end as var2&lt;BR /&gt;
&lt;BR /&gt;
OR&lt;BR /&gt;
&lt;BR /&gt;
coalesce(var1,0) as var2&lt;BR /&gt;
&lt;BR /&gt;
thanks,&lt;BR /&gt;
milton</description>
    <pubDate>Mon, 09 Aug 2010 01:39:08 GMT</pubDate>
    <dc:creator>milts</dc:creator>
    <dc:date>2010-08-09T01:39:08Z</dc:date>
    <item>
      <title>coalesce or case-when efficiency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61643#M13389</link>
      <description>hi experts,&lt;BR /&gt;
&lt;BR /&gt;
i'd like to check a variable if it is null or missing. if so, i'll assign the value 0 to another column, else the other column will just take it's value.&lt;BR /&gt;
&lt;BR /&gt;
which between these two is more efficient?&lt;BR /&gt;
&lt;BR /&gt;
case when var1 not is missing then var1 else 0 end as var2&lt;BR /&gt;
&lt;BR /&gt;
OR&lt;BR /&gt;
&lt;BR /&gt;
coalesce(var1,0) as var2&lt;BR /&gt;
&lt;BR /&gt;
thanks,&lt;BR /&gt;
milton</description>
      <pubDate>Mon, 09 Aug 2010 01:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61643#M13389</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2010-08-09T01:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce or case-when efficiency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61644#M13390</link>
      <description>Hi:&lt;BR /&gt;
  This might be one of those instances where "your mileage may vary" depending on the rest of your query and the size of the file(s) being accessed/created. Running some benchmarks might be in order.&lt;BR /&gt;
 &lt;BR /&gt;
  A review of the doc might be in order too:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002206368.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002206368.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
  I have to think there was -some- reason for this note in the doc:&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
Note:   If your query contains a large number of COALESCE function calls, it might be more efficient to use a natural join instead. See Natural Joins.  &lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 09 Aug 2010 03:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61644#M13390</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-08-09T03:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: coalesce or case-when efficiency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61645#M13391</link>
      <description>Thank you very much for the input Cynthia.&lt;BR /&gt;
&lt;BR /&gt;
Milton</description>
      <pubDate>Tue, 10 Aug 2010 00:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/coalesce-or-case-when-efficiency/m-p/61645#M13391</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2010-08-10T00:50:50Z</dc:date>
    </item>
  </channel>
</rss>

