<?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: FedSQL Convert and Compare current_date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490426#M128302</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello ChrisNZ, Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The different types I mean are about the field called "DATE" and the system variable "current_date". The first one is Numeric, and after use the function PUT it will be transformed into Double, right? And the second one is a date, and I don´t know what type it will be after PUT function, anyway, the result of this example I gave is 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have another function or logic to do this count comparing these fields?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2018 11:59:53 GMT</pubDate>
    <dc:creator>Uemerson</dc:creator>
    <dc:date>2018-08-28T11:59:53Z</dc:date>
    <item>
      <title>FedSQL Convert and Compare current_date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/488890#M127503</link>
      <description>&lt;P&gt;Hello experts!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am trying to convert the code below (Oracle SQL) to FedSQL used by SAS DataFlux. The field called in this example "DATE" is a numeric type with the format 'yyyymmdd'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp;Type&lt;/P&gt;&lt;P&gt;DATE&amp;nbsp; &amp;nbsp;&amp;nbsp;NUMBER(8)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select count(0) AS Ten_Days_Before&lt;BR /&gt;from [TABLE]&lt;BR /&gt;where DATE = TO_CHAR(SYSDATE-10, 'yyyymmdd');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I tried the function "PUT" with the code below, but It´s not working because of different data types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select count(0) AS&amp;nbsp;&lt;SPAN&gt;Ten_Days_Before&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;from&amp;nbsp;&lt;SPAN&gt;[TABLE]&lt;/SPAN&gt;&lt;BR /&gt;where PUT(&lt;SPAN&gt;DATE&lt;/SPAN&gt;,&lt;SPAN&gt;yymmddn8.&lt;/SPAN&gt;) = PUT(current_date-10,yymmddn8.) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 14:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/488890#M127503</guid>
      <dc:creator>Uemerson</dc:creator>
      <dc:date>2018-08-22T14:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: FedSQL Convert and Compare current_date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/489101#M127596</link>
      <description>&lt;P&gt;1. &lt;EM&gt;&amp;nbsp;It´s not working because of different data types.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;What are the data types?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. If this works&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp;put(&lt;/SPAN&gt;&lt;SPAN&gt;DATE&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;yymmddn8.&lt;/SPAN&gt;&lt;SPAN&gt;) = put(CURRENT_DATE-10,yymmddn8.)&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;then this works&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp;DATE&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= CURRENT_DATE-10&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;(not that it's better, just different and a tad faster)&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 00:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/489101#M127596</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-23T00:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: FedSQL Convert and Compare current_date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490426#M128302</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello ChrisNZ, Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The different types I mean are about the field called "DATE" and the system variable "current_date". The first one is Numeric, and after use the function PUT it will be transformed into Double, right? And the second one is a date, and I don´t know what type it will be after PUT function, anyway, the result of this example I gave is 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have another function or logic to do this count comparing these fields?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 11:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490426#M128302</guid>
      <dc:creator>Uemerson</dc:creator>
      <dc:date>2018-08-28T11:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: FedSQL Convert and Compare current_date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490648#M128422</link>
      <description>&lt;P&gt;1. I am confused as to what the values are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;gt;&lt;EM&gt;The first on&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;EM&gt;e is Numeric&amp;nbsp;&lt;/EM&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is it a SAS date like 23056?&amp;nbsp; Or a number expressing a date like 20180612?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;And the second one is a date, and I don´t know what type it will be after PUT function,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;A date should probably not&amp;nbsp;need using PUT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide the raw untransformed values for each, for example&amp;nbsp;the first lines of :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;select DATE, SYSDATE from TABLE&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. I am confused as to where you run your query.&lt;/P&gt;
&lt;P&gt;This is invalid SAS code:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; select count(0) AS Ten_Days_Before &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; from [TABLE] &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; where DATE = TO_CHAR(SYSDATE-10, 'yyyymmdd');&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;while this is only valid in SAS:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; select count(0) AS&amp;nbsp;&lt;SPAN&gt;Ten_Days_Before&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; from&amp;nbsp;&lt;SPAN&gt;[TABLE]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; where PUT(&lt;SPAN&gt;DATE&lt;/SPAN&gt;,&lt;SPAN&gt;yymmddn8.&lt;/SPAN&gt;) = PUT(current_date-10,yymmddn8.) ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So which one is it? Where do you run the code? Please provide full code and log.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 21:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490648#M128422</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-28T21:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: FedSQL Convert and Compare current_date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490763#M128501</link>
      <description>&lt;P&gt;Hi ChrisNZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The field "DATE" is&amp;nbsp;a number expressing a date (Ex.: 20180829).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. My query was running in Oracle SQL, now I need to migrate the code to SAS DataFlux.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I tried the code below, and It works well. I think that the problem was the format used with PUT function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;select count(0) AS&amp;nbsp;&lt;SPAN&gt;Ten_Days_Before&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; from&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[TABLE]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; where &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PUT(&lt;SPAN&gt;DATE&lt;/SPAN&gt;,&lt;STRONG&gt;8.&lt;/STRONG&gt;) = PUT(current_date-10,yymmddn8.) ;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 09:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490763#M128501</guid>
      <dc:creator>Uemerson</dc:creator>
      <dc:date>2018-08-29T09:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: FedSQL Convert and Compare current_date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490765#M128503</link>
      <description>It's clearer now. &lt;BR /&gt;where&amp;nbsp;input(DATE,yymmddn8.) = current_date-10 ;&amp;nbsp;&lt;BR /&gt;orwhere&amp;nbsp;input(DATE,yymmdd8.) = current_date-10 ;&amp;nbsp;would probably work too. Not that it's better. Just to show how to compare dates rather than strings.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Aug 2018 09:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FedSQL-Convert-and-Compare-current-date/m-p/490765#M128503</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-29T09:18:31Z</dc:date>
    </item>
  </channel>
</rss>

