<?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: Proc Fedsql - Date and Macro variable resolution in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951115#M371844</link>
    <description>&lt;P&gt;It seems to be after the %TSLIT macro function is called it converts the date from date9 to character.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2024 16:32:51 GMT</pubDate>
    <dc:creator>phopkinson</dc:creator>
    <dc:date>2024-11-18T16:32:51Z</dc:date>
    <item>
      <title>Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951109#M371839</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a piece of code which selects the date between two macro variables (Var1 and Var2) - however in proc fedsql these don't seem to resolve within the %TSLIT() function to a comparable date value. Is there a way to get them to work in my where clause?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 15:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951109#M371839</guid>
      <dc:creator>phopkinson</dc:creator>
      <dc:date>2024-11-18T15:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951110#M371840</link>
      <description>&lt;P&gt;Can you share the code that generates the two macro variables? And maybe provide some examples that "don't work". And the subsequent call to %TSLIT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A very common problem with macro variables and "date" values is applying a format to the value and then attempting to use the result in a comparison or calculation. Generally the formatted values don't do well because the behave as character values and things like 11/05/2024 don't evaluate well when compared to 01/05/2025 (as in the first is "larger" than the second because of the rules used for comparison of strings).&amp;nbsp; OR&amp;nbsp; 11/05/2024 gets treated as multiple division operations as it would here and is why x = 0.0010869565 (more or less)&lt;/P&gt;
&lt;PRE&gt;data junk;
   x = 11/05/2024;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 15:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951110#M371840</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-11-18T15:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951111#M371841</link>
      <description>&lt;P&gt;SHOW US the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have macro variables, turn on the macro debugging options, run the code again and then also show us the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2024 15:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951111#M371841</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-18T15:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951113#M371842</link>
      <description>&lt;P&gt;The code that generates the macro variables is completely fine and not the cause of my issue - I can't share that part anyway I'm afraid.&amp;nbsp; This is the where condition which I am certain is causing the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE %TSLIT(&amp;amp;VAR1.) &amp;lt;= date &amp;lt;= %TSLIT(&amp;amp;VAR2.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the error message that I get in the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Operator does not exist: bool &amp;lt;= CHAR&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 15:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951113#M371842</guid>
      <dc:creator>phopkinson</dc:creator>
      <dc:date>2024-11-18T15:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951114#M371843</link>
      <description>&lt;P&gt;What are the values of &amp;amp;VAR1 and &amp;amp;VAR2? What are the typical values of variable DATE, un-formatted? What format is assigned to variable DATE? Is DATE numeric or character?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951114#M371843</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-18T16:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951115#M371844</link>
      <description>&lt;P&gt;It seems to be after the %TSLIT macro function is called it converts the date from date9 to character.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951115#M371844</guid>
      <dc:creator>phopkinson</dc:creator>
      <dc:date>2024-11-18T16:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951116#M371845</link>
      <description>&lt;P&gt;Is your FEDSQL sending the code off to POSTGRES?&amp;nbsp; It looks like a Postgres error message.&amp;nbsp; See e.g. this thread:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Error-in-PROC-SQL-query/td-p/859565" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Error-in-PROC-SQL-query/td-p/859565&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to remove the macro factor, try writing your code with hard coded values, and I expect you'll get the same error message, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE '2024-01-01' &amp;lt;= date &amp;lt;= '2024-12-31';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, that syntax of chained operators, x&amp;lt;y&amp;lt;z is allowed in SAS, but is not common in other languages, so I would try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE ('2024-01-01' &amp;lt;= date) and (date &amp;lt;= '2024-12-31') ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error message says you're comparing a boolean value (true false) to a character value, which isn't allowed in Postgres.&amp;nbsp; That would happen if postgres isn't evaluating x&amp;lt;y&amp;lt;z as a single boolean expression.&amp;nbsp; Instead it's doing (x&amp;lt;y)&amp;lt;z.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then once you get the code working without %TSLIT, go back to trying to use %TSLIT to add the single quotes.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951116#M371845</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-11-18T16:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951117#M371846</link>
      <description>&lt;P&gt;Looks like it complaining about the operators, not the values.&lt;/P&gt;
&lt;P&gt;Are you sure that PROC FEDSQL supports SAS's abbreviated comparison syntax that treats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a op1 b op2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as meaning&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(a op1 b) and (b op2 c)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;??&lt;/P&gt;
&lt;P&gt;What happens if you spell things out for FEDSQL?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE (%TSLIT(&amp;amp;VAR1.) &amp;lt;= date) and (date &amp;lt;= %TSLIT(&amp;amp;VAR2.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951117#M371846</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-11-18T16:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Fedsql - Date and Macro variable resolution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951118#M371847</link>
      <description>&lt;P&gt;You were right it was the use of the chained operators that caused the problem. Thank you very much for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 16:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Fedsql-Date-and-Macro-variable-resolution/m-p/951118#M371847</guid>
      <dc:creator>phopkinson</dc:creator>
      <dc:date>2024-11-18T16:38:30Z</dc:date>
    </item>
  </channel>
</rss>

