<?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 date handling in fedsql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801025#M315214</link>
    <description>&lt;P&gt;These 2 approaches works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date '2022-02-01' &amp;lt;= _fecformo and _fecformo &amp;lt;= date '2022-02-24'   
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;

%let date1='2022-02-01';
proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date &amp;amp;date1 &amp;lt;= _fecformo and _fecformo &amp;lt;= date '2022-02-24'   
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But this fails:&lt;/P&gt;
&lt;P&gt;I don't now how to single quote correctly the character converted date expression.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date '2022-02-01' &amp;lt;= _fecformo and _fecformo &amp;lt;= date "'"||put(today(), yymmdd10.)||"'"   
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Mar 2022 09:46:40 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2022-03-09T09:46:40Z</dc:date>
    <item>
      <title>date handling in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801025#M315214</link>
      <description>&lt;P&gt;These 2 approaches works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date '2022-02-01' &amp;lt;= _fecformo and _fecformo &amp;lt;= date '2022-02-24'   
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;

%let date1='2022-02-01';
proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date &amp;amp;date1 &amp;lt;= _fecformo and _fecformo &amp;lt;= date '2022-02-24'   
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But this fails:&lt;/P&gt;
&lt;P&gt;I don't now how to single quote correctly the character converted date expression.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date '2022-02-01' &amp;lt;= _fecformo and _fecformo &amp;lt;= date "'"||put(today(), yymmdd10.)||"'"   
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Mar 2022 09:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801025#M315214</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-09T09:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: date handling in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801028#M315216</link>
      <description>&lt;P&gt;It does not even work when I create the char date variables before in a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data step:
help_date=quote(put(today(), yymmdd10.), "'");
help_date1=quote(put(today(), yymmdd10.));
help_date2=put(today(), yymmdd10.);

proc cas;
    source MPG_toyota;
        select distinct producto, from_brand, count(*) as cnt
        from MKT.CARTERA_NODUP where date '2022-02-01' &amp;lt;= _fecformo and _fecformo &amp;lt;= date help_date2
        group by producto, from_brand having from_brand in ('Volkswagen', 'Audi')  ;
    endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It says&amp;nbsp;ERROR: Syntax error at or near "HELP_DATE2"&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 10:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801028#M315216</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-09T10:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: date handling in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801053#M315226</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127222"&gt;@acordes&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My SAS installation doesn't include PROC CAS, so I can't test my suggestion:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(quote(%sysfunc(today(),yymmdd10.),%str(%')))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Mar 2022 12:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801053#M315226</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-03-09T12:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: date handling in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801055#M315228</link>
      <description>&lt;P&gt;Why don't you keep everything as SAS dates and avoid the typecast?&lt;/P&gt;
&lt;P&gt;In the data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;help_date2 = today();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and in the SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where '01feb2022'd &amp;lt;= _fecformo and _fecformo &amp;lt;= help_date2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 12:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801055#M315228</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-09T12:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: date handling in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801073#M315239</link>
      <description>&lt;P&gt;You're right for this example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the need arose when I wanted to run in fedsql what I had done before in sql.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in this query I hard-coded the date range and I begun to put '01feb2022'd within the fedsql source code. That works for sql but not for fedsql...&lt;/P&gt;
&lt;P&gt;If I have the date as numeric in my table I can use it without problems.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 13:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-handling-in-fedsql/m-p/801073#M315239</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-09T13:50:00Z</dc:date>
    </item>
  </channel>
</rss>

