<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625720#M184461</link>
    <description>Is it COALESCE or CAST() that's causing the issue? SAS doesn't have a CAST function, you would use PUT() or INPUT() there depending on what you're trying to do. The actual error would indicate where the issue is.</description>
    <pubDate>Tue, 18 Feb 2020 22:46:58 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-02-18T22:46:58Z</dc:date>
    <item>
      <title>Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625718#M184460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Getting an error when using the coalesce function below that works with standard ANSI SQL. Any ideas how to modify?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table xxxxxxxxxxx as&lt;/P&gt;&lt;P&gt;select lp.epoch_interval_time,&lt;BR /&gt;divide ( mod ( lp.epoch_interval_time - 7*3600 , 86400 ), 3600 ) as intv_hr,&lt;BR /&gt;divide ( mod ( lp.epoch_interval_time - 7*3600 , 86400 ), 3600 )+ 1 as intrvl_24hr_ending,&lt;BR /&gt;lp.local_interval_time,&lt;BR /&gt;lp.utc_interval_time,&lt;BR /&gt;lp.lp_value,&lt;BR /&gt;lp.validation_status,&lt;BR /&gt;lp.lp_interval_length,&lt;BR /&gt;sdps.udc_id as sp&lt;BR /&gt;from xxxxxxxxxxxxxxx&lt;BR /&gt;join xxxxxxxxxxxxxxxxxx on lp.channel_id = chn.channel_id&lt;BR /&gt;and chn.channel_type = 'Interval Data'&lt;BR /&gt;and chn.physical_channel_no in (1,11,21)&lt;BR /&gt;&lt;BR /&gt;join xxxxxxxxxxxxx on chn.sdp_id = sdps.sdp_id&lt;BR /&gt;where lp.utc_interval_yr_mth in (201910,201909)&lt;BR /&gt;&lt;STRONG&gt;AND (lp.utc_interval_time &amp;gt;= chn.start_date AND lp.utc_interval_time &amp;lt;= COALESCE(chn.end_date, CAST('2099-01-01 01:00:00' as TIMESTAMP)))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND sdps.meter_id = chn.meter_id &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND (lp.utc_interval_time &amp;gt;= sdps.start_date AND lp.utc_interval_time &amp;lt;= COALESCE(sdps.end_date, CAST('2099-01-01 01:00:00' as TIMESTAMP)))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 22:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625718#M184460</guid>
      <dc:creator>dkassis</dc:creator>
      <dc:date>2020-02-18T22:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625720#M184461</link>
      <description>Is it COALESCE or CAST() that's causing the issue? SAS doesn't have a CAST function, you would use PUT() or INPUT() there depending on what you're trying to do. The actual error would indicate where the issue is.</description>
      <pubDate>Tue, 18 Feb 2020 22:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625720#M184461</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-18T22:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625731#M184468</link>
      <description>&lt;P&gt;&lt;STRONG&gt;cast('2099-01-01 01:00:00' as TIMESTAMP)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;is written&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;'01jan2099:01:00:00'dt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;in SAS.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please look at your log messages more carefully, I suspect SAS complained loudly about your calling a non-existing function.&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>Wed, 19 Feb 2020 00:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625731#M184468</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-19T00:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625769#M184489</link>
      <description>&lt;P&gt;I suspect this is a cast issue.&amp;nbsp; Here is the error I am getting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;__&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !,&lt;BR /&gt;!!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;,&lt;BR /&gt;&amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET,&lt;BR /&gt;GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET,&lt;BR /&gt;NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and&lt;BR /&gt;will be ignored.&lt;/P&gt;&lt;P&gt;47 AND sdps.meter_id = chn.meter_id&lt;BR /&gt;48 AND (lp.utc_interval_time &amp;gt;= sdps.start_date AND&lt;BR /&gt;48 ! lp.utc_interval_time &amp;lt;=&lt;BR /&gt;48 ! COALESCE(sdps.end_date,'01jan2099:01:00:00'dt&lt;BR /&gt;48 ! /*CAST('2099-01-01 01:00:00'*/ as TIMESTAMP))&lt;BR /&gt;__&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !,&lt;BR /&gt;!!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;,&lt;BR /&gt;&amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET,&lt;BR /&gt;GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET,&lt;BR /&gt;NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and&lt;BR /&gt;will be ignored.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 03:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625769#M184489</guid>
      <dc:creator>dkassis</dc:creator>
      <dc:date>2020-02-19T03:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625791#M184500</link>
      <description>&lt;P&gt;Are you now just showing us or do you still not know how to fix the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the log you've posted:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Always show the very first error in the log. You haven't posted the code which causes the first error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the 2nd error where you also show the code: You haven't commented out correctly.&lt;/P&gt;
&lt;P&gt;What you've done:&lt;/P&gt;
&lt;PRE&gt;COALESCE(sdps.end_date,'01jan2099:01:00:00'dt /*CAST('2099-01-01 01:00:00'*/ as TIMESTAMP))&lt;/PRE&gt;
&lt;P&gt;How it should look like:&lt;/P&gt;
&lt;PRE&gt;COALESCE(sdps.end_date,'01jan2099:01:00:00'dt /*CAST('2099-01-01 01:00:00' as TIMESTAMP)*/)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 07:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625791#M184500</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-19T07:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625806#M184506</link>
      <description>&lt;P&gt;Did you replace the cast() value as shown?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 09:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625806#M184506</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-19T09:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625863#M184531</link>
      <description>&lt;P&gt;Sorry for the confusion, when I commented out the cast the error went away.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 15:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625863#M184531</guid>
      <dc:creator>dkassis</dc:creator>
      <dc:date>2020-02-19T15:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625966#M184565</link>
      <description>&lt;P&gt;Code seem over complicated, especially that mod/div stuff.&amp;nbsp; Looks like you are just trying to pull out the HOUR, after subtracting 7 hours.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table xxxxxxxxxxxxxxx as
select lp.epoch_interval_time
     , hour(intnx('hour',lp.epoch_interval_time,-7)) as intv_hr
     , calculated intv_hr + 1 as intrvl_24hr_ending
     , lp.local_interval_time
     , lp.utc_interval_time
     , lp.lp_value
     , lp.validation_status
     , lp.lp_interval_length
     , sdps.udc_id as sp
from xxxxxxxxxxxxxxx lp
join xxxxxxxxxxxxxxx chn
  on lp.channel_id = chn.channel_id
 and chn.channel_type = 'Interval Data'
 and chn.physical_channel_no in (1,11,21)
join xxxxxxxxxxxxxxx sdps
  on chn.sdp_id = sdps.sdp_id
where lp.utc_interval_yr_mth in (201910,201909)
  AND lp.utc_interval_time &amp;gt;= chn.start_date
  AND lp.utc_interval_time &amp;lt;= COALESCE(chn.end_date, "01JAN2099:01:00"dt)
  AND sdps.meter_id = chn.meter_id
  AND lp.utc_interval_time &amp;gt;= sdps.start_date
  AND lp.utc_interval_time &amp;lt;= COALESCE(sdps.end_date, "01JAN2099:01:00"dt)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why are some of the conditions in the WHERE clause not included into the ON clause? Like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  AND sdps.meter_id = chn.meter_id&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 19:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625966#M184565</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-19T19:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625973#M184571</link>
      <description>&lt;P&gt;To add a little more context, this data is pulling from a Hadoop platform.&amp;nbsp; I&amp;nbsp;have to convert EPOCH time (integer) to readable time hence the calculation.&amp;nbsp; I am working on developing and testing a new table structure that extracts 15 minute interval data and then will roll it up to hourly and daily data in subsequent tables I am doing those steps in a series of proc means with a limited amount of data just for testing purposes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the code above from my ETL developer who doesn't use SAS but BDM or DB visualizer, so I have to translate to SAS.&amp;nbsp; I want to ensure all the code runs in hadoop for optimal performance so I want to make sure I use supported functions within the SAS/ACCESS engine.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code won't run entirely in Hadoop but I have what I need for now until my developer gets back.&amp;nbsp; Thanks for all the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625973#M184571</guid>
      <dc:creator>dkassis</dc:creator>
      <dc:date>2020-02-19T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625977#M184573</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;ensure all the code runs in hadoop for optimal performance&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why don't you use the Hadoop code in a pass-through query then? Just an idea.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 03:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/625977#M184573</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-20T03:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/626039#M184582</link>
      <description>&lt;P&gt;"&lt;EM&gt;I got the code above from my ETL developer who doesn't use SAS but BDM or DB visualizer, so I have to translate to SAS.&amp;nbsp; I want to ensure all the code runs in hadoop for optimal performance so I want to make sure I use supported functions within the SAS/ACCESS engine.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS Access engines allow you to pass code directly to a database for execution (explicit pass-through). So if you've already got working Hive SQL then that's what I'd be doing: Just copy/paste this Hive SQL into the EXECUTE block.&lt;/P&gt;
&lt;P&gt;Also: If you want everything working in Hadoop and you then want to hand-over this code for implementation not using SAS at all then I'd be using Hue or DBeaver for development of Hive SQL.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 03:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesce/m-p/626039#M184582</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-20T03:00:19Z</dc:date>
    </item>
  </channel>
</rss>

