<?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 based where clause in fedsql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885572#M349952</link>
    <description>&lt;P&gt;I cannot figure out how to make this work in fedsql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_fec_unic is numeric with date format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot use year(_fec_unic)=2023.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I hard code a date like year(date'2023-03-28')=2023 it works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my attempts fail to use it with the date variable.&amp;nbsp;&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 cod_conc, cod_mrc, sum(num) as uds, sum(denum) as vtas
               from ONAIR.HIERARCHY_GC_COCKPIT_V14 where cod_conc='0311P' and transaction='GC Privado' and
		year(cats('date', put(_fec_unic, yymmdd10.))) = 2023 
				group by cod_conc, cod_mrc ;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Jul 2023 08:28:25 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2023-07-20T08:28:25Z</dc:date>
    <item>
      <title>date based where clause in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885572#M349952</link>
      <description>&lt;P&gt;I cannot figure out how to make this work in fedsql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_fec_unic is numeric with date format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot use year(_fec_unic)=2023.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I hard code a date like year(date'2023-03-28')=2023 it works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my attempts fail to use it with the date variable.&amp;nbsp;&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 cod_conc, cod_mrc, sum(num) as uds, sum(denum) as vtas
               from ONAIR.HIERARCHY_GC_COCKPIT_V14 where cod_conc='0311P' and transaction='GC Privado' and
		year(cats('date', put(_fec_unic, yymmdd10.))) = 2023 
				group by cod_conc, cod_mrc ;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2023 08:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885572#M349952</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-07-20T08:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: date based where clause in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885642#M349981</link>
      <description>Try it with something like: "put(_fec_unic, year.) = '2023'" instead of "year(cats('date', put(_fec_unic, yymmdd10.))) = 2023".</description>
      <pubDate>Thu, 20 Jul 2023 15:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885642#M349981</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-07-20T15:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: date based where clause in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885643#M349982</link>
      <description>&lt;P&gt;That does not look at all equivalent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATE&amp;nbsp;'2023-03-28'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is a DATE literal in many SQL implementation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cats('date', put(_fec_unic, yymmdd10.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is generating a STRING , which is invalid as the input to the YEAR() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;_fec_unic has DATE values in it (which is required for the YYMMDD format to work) then you should be able to just use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; YEAR(_fec_unic)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If instead it has DATETIME values (ie number of seconds since 1960 instead of number of days) then you will need to also include DATEPART() function to convert the seconds into days.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; YEAR(DATEPART(_fec_unic))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 15:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-based-where-clause-in-fedsql/m-p/885643#M349982</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-20T15:20:44Z</dc:date>
    </item>
  </channel>
</rss>

