<?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: Automate query filter by date in SAS Academy for Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784570#M1095</link>
    <description>&lt;P&gt;i tried using macro like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let date = %SYSFUNC(today(), year4.);&amp;nbsp; &lt;EM&gt;/*if current date is 07-12-2021, i want to take the year so the result that i expected is 2021*/&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;connect to oracle (USER="xxxx" PASSWORD="xxxxx"&lt;BR /&gt;PATH="(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)&lt;BR /&gt;(HOST = xxxx) (PORT = xxxx)))(CONNECT_DATA =(SID = xxxx )))");&lt;BR /&gt;create table newccv2.card_0 (COMPRESS=YES) as&lt;BR /&gt;select * from connection to oracle&lt;BR /&gt;(&lt;BR /&gt;select distinct *&lt;BR /&gt;from BMDM_COMM.CREDIT_CARD_ACCOUNT&lt;BR /&gt;where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;OPENING_DATEKEY like&lt;STRONG&gt; '&amp;amp;date.%'&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;EM&gt;/* when the macro (%let date) from above, i expected&amp;nbsp;where&amp;nbsp;OPENING_DATEKEY like '2021%*/&lt;/EM&gt;&lt;BR /&gt;);&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it didnt' work, is there another way?&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 17:13:36 GMT</pubDate>
    <dc:creator>BL_463_IDR</dc:creator>
    <dc:date>2021-12-07T17:13:36Z</dc:date>
    <item>
      <title>Automate query filter by date</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784249#M1093</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;i want to automate query by date, based on current year (date system on pc/laptop). For information the value of date (&lt;STRONG&gt;OPENING_DATEKEY&lt;/STRONG&gt;) that i want to filter is '20210101' (text/string).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example,&amp;nbsp;the filter date that i currently query like below&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;connect to oracle (USER="xxxx" PASSWORD="xxxxx"&lt;BR /&gt;PATH="(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)&lt;BR /&gt;(HOST = xxxx) (PORT = xxxx)))(CONNECT_DATA =(SID = xxxx )))");&lt;BR /&gt;create table newccv2.card_0 (COMPRESS=YES) as&lt;BR /&gt;select * from connection to oracle&lt;BR /&gt;(&lt;BR /&gt;select distinct *&lt;BR /&gt;from BMDM_COMM.CREDIT_CARD_ACCOUNT&lt;BR /&gt;where &lt;STRONG&gt;OPENING_DATEKEY like '2021%'&lt;/STRONG&gt;&lt;BR /&gt;);&lt;BR /&gt;QUIT;&lt;BR /&gt;&lt;BR /&gt;thanks for your attention.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 07:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784249#M1093</guid>
      <dc:creator>BL_463_IDR</dc:creator>
      <dc:date>2021-12-06T07:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Automate query filter by date</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784279#M1094</link>
      <description>&lt;P&gt;What is wrong with the code you show?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 11:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784279#M1094</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-06T11:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Automate query filter by date</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784570#M1095</link>
      <description>&lt;P&gt;i tried using macro like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let date = %SYSFUNC(today(), year4.);&amp;nbsp; &lt;EM&gt;/*if current date is 07-12-2021, i want to take the year so the result that i expected is 2021*/&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;connect to oracle (USER="xxxx" PASSWORD="xxxxx"&lt;BR /&gt;PATH="(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)&lt;BR /&gt;(HOST = xxxx) (PORT = xxxx)))(CONNECT_DATA =(SID = xxxx )))");&lt;BR /&gt;create table newccv2.card_0 (COMPRESS=YES) as&lt;BR /&gt;select * from connection to oracle&lt;BR /&gt;(&lt;BR /&gt;select distinct *&lt;BR /&gt;from BMDM_COMM.CREDIT_CARD_ACCOUNT&lt;BR /&gt;where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;OPENING_DATEKEY like&lt;STRONG&gt; '&amp;amp;date.%'&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;EM&gt;/* when the macro (%let date) from above, i expected&amp;nbsp;where&amp;nbsp;OPENING_DATEKEY like '2021%*/&lt;/EM&gt;&lt;BR /&gt;);&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it didnt' work, is there another way?&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 17:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784570#M1095</guid>
      <dc:creator>BL_463_IDR</dc:creator>
      <dc:date>2021-12-07T17:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Automate query filter by date</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784574#M1096</link>
      <description>&lt;P&gt;For your future benefit: Saying it "didn't work" and providing no additional information doesn't get us anywhere.&amp;nbsp;If there are errors in the log, then show us the log for the run of this macro. If the output is incorrect, then show us the incorrect output (and explain what the correct output should be).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this particular case, one problem is obvious (although there may be other problems).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'&amp;amp;date.%'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will never work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need double-quotes here to get it to work, and you will need to mask the percent sign. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;date%nrstr(%%)"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if Oracle does not work with double-quotes, then you need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%nrstr(%')&amp;amp;date%nrstr(%%)%nrstr(%')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 17:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/784574#M1096</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-07T17:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Automate query filter by date</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/785105#M1097</link>
      <description>&lt;P&gt;Dear Page Miller&lt;BR /&gt;&lt;BR /&gt;Thank you for your solution, i used this and it's works as expected.&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;%nrstr(%')&amp;amp;date%nrstr(%%)%nrstr(%')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i'm sorry for didn't provide additional information for the case, next ill fix it and explain more clear.&amp;nbsp;&lt;BR /&gt;Once again, thanks for your solution.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 08:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Automate-query-filter-by-date/m-p/785105#M1097</guid>
      <dc:creator>BL_463_IDR</dc:creator>
      <dc:date>2021-12-09T08:50:44Z</dc:date>
    </item>
  </channel>
</rss>

