<?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: Macro variables for date and integer in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901314#M11155</link>
    <description>&lt;P&gt;Thank you Tom! That worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know what I should try for the month_number variable?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Nov 2023 22:35:05 GMT</pubDate>
    <dc:creator>Wickedestjr</dc:creator>
    <dc:date>2023-11-02T22:35:05Z</dc:date>
    <item>
      <title>Macro variables for date and integer</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901305#M11153</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to incorporate three different macro variables into a program that otherwise works just fine. I've tried searching for solutions online, but am struggling to find anything that fixes these problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro variables are set up at the beginning of the program:&lt;/P&gt;&lt;P&gt;%let month_number = 8;&lt;/P&gt;&lt;P&gt;%let month = 202308;&lt;/P&gt;&lt;P&gt;%let day = 20230831;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, I am trying to create a table:&lt;/P&gt;&lt;P&gt;data table2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; set table1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if PROCESS_YYYYMM &amp;lt;= (INCURRED_DT_YR_2) * 100 + &amp;amp;month_number.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; then...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;I'm getting a syntax error when I try using the &amp;amp;month_number. variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, the program has a step where it connects to a server and creates a table with the following WHERE statement:&lt;/P&gt;&lt;P&gt;WHERE&lt;/P&gt;&lt;P&gt;t1.PROCESS_YYYYMM between '201601' and '202308' and&lt;/P&gt;&lt;P&gt;t2.INCURRED_DT_DAY between '20160101' and '20230831'&lt;/P&gt;&lt;P&gt;The program works just fine like this, but I'd like to incorporate the &amp;amp;month. and &amp;amp;day. variables in lieu of the end dates shown here. How do I need to format this? I've tried a number of different possibilities with apostrophes, quotation marks, and even tried using a %syslput line for each variable before this table gets created, but nothing that I've tried seems to work. I keep getting ERROR: CLI execute error and the table doesn't get created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 21:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901305#M11153</guid>
      <dc:creator>Wickedestjr</dc:creator>
      <dc:date>2023-11-02T21:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables for date and integer</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901308#M11154</link>
      <description>&lt;P&gt;If the macro is generating SAS code then just use double quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;     t1.PROCESS_YYYYMM between '201601' and "&amp;amp;month"
 and t2.INCURRED_DT_DAY between '20160101' and "&amp;amp;day"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are pushing that code into some external database that does not recognize double quotes are character constants then you will have to work a little harder to get the single quotes instead.&amp;nbsp; Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;     t1.PROCESS_YYYYMM between '201601' and %bquote('&amp;amp;month')
 and t2.INCURRED_DT_DAY between '20160101' and %bquote('&amp;amp;day')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 21:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901308#M11154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-02T21:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables for date and integer</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901314#M11155</link>
      <description>&lt;P&gt;Thank you Tom! That worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know what I should try for the month_number variable?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 22:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901314#M11155</guid>
      <dc:creator>Wickedestjr</dc:creator>
      <dc:date>2023-11-02T22:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables for date and integer</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901317#M11156</link>
      <description>&lt;P&gt;If the code comparing the variable to a quoted string worked then you don't want to treat it as if it was a number like you have in the other code.&amp;nbsp; Unless you are talking about two different variables (from different datasets) that just happen to have the same name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what do you think this code is doing?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    if PROCESS_YYYYMM &amp;lt;= (INCURRED_DT_YR_2) * 100 + &amp;amp;month_number.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is&amp;nbsp;INCURRED_DT_YR_2?&amp;nbsp; Is that a numeric variable?&amp;nbsp; What types of values does it have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It it is a NUMBER than convert it to a character string and append a character version of &amp;amp;MONTH_NUMBER.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    if PROCESS_YYYYMM &amp;lt;=  put(INCURRED_DT_YR_2,Z4.) || put( &amp;amp;month_number.,Z2.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Nov 2023 23:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Macro-variables-for-date-and-integer/m-p/901317#M11156</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-02T23:32:29Z</dc:date>
    </item>
  </channel>
</rss>

