<?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 Putting a macro variable inside single quotations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758005#M239301</link>
    <description>&lt;P&gt;I have the following macro variable(s)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%LET LIVE_DATE = 07JUL2021;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;BR /&gt;CALL SYMPUT('DAY_NUM',WEEKDAY("&amp;amp;LIVE_DATE"D));&lt;BR /&gt;RUN;&lt;BR /&gt;%PUT &amp;amp;DAY_NUM;&lt;BR /&gt;&lt;BR /&gt;So DAY_NUM returns the value 4 and I want to use DAY_NUM in place of the hardcoded 4 later within the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;WEEK_START = INTNX('WEEK1.4',DTE_RCVD,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I can't figure out how to do this ... &amp;amp;, &amp;amp;&amp;amp;, how many quotation marks, where ??&lt;BR /&gt;Is it even possible?&lt;BR /&gt;&lt;BR /&gt;Any help appreciated, thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jul 2021 08:30:38 GMT</pubDate>
    <dc:creator>girl_withno_nam</dc:creator>
    <dc:date>2021-07-29T08:30:38Z</dc:date>
    <item>
      <title>Putting a macro variable inside single quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758005#M239301</link>
      <description>&lt;P&gt;I have the following macro variable(s)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%LET LIVE_DATE = 07JUL2021;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;BR /&gt;CALL SYMPUT('DAY_NUM',WEEKDAY("&amp;amp;LIVE_DATE"D));&lt;BR /&gt;RUN;&lt;BR /&gt;%PUT &amp;amp;DAY_NUM;&lt;BR /&gt;&lt;BR /&gt;So DAY_NUM returns the value 4 and I want to use DAY_NUM in place of the hardcoded 4 later within the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;WEEK_START = INTNX('WEEK1.4',DTE_RCVD,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I can't figure out how to do this ... &amp;amp;, &amp;amp;&amp;amp;, how many quotation marks, where ??&lt;BR /&gt;Is it even possible?&lt;BR /&gt;&lt;BR /&gt;Any help appreciated, thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 08:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758005#M239301</guid>
      <dc:creator>girl_withno_nam</dc:creator>
      <dc:date>2021-07-29T08:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Putting a macro variable inside single quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758008#M239302</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390808"&gt;@girl_withno_nam&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, use &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1fa0ay5pzr9yun1mvqxv8ipzd4d.htm" target="_blank" rel="noopener"&gt;CALL SYMPUT&lt;STRONG&gt;X&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;instead of CALL SYMPUT to avoid leading blanks in macro variable DAY_NUM and an unwanted note (about numeric-to-character conversion) in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then replace the single quotes in the first argument of the INTNX function with double quotes and the hardcoded 4 with the macro variable reference as usual:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;WEEK1.&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;&amp;amp;DAY_NUM"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Alternatively, if &amp;amp;DAY_NUM is used only in that INTNX function call, you can plug in the definition directly, without the preceding DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;WEEK.&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;%sysfunc(weekday("&amp;amp;live_date"d))&lt;/FONT&gt;&lt;FONT color="#3366FF"&gt;"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;(Omitted the redundant "&lt;FONT face="courier new,courier"&gt;1&lt;/FONT&gt;" after "&lt;FONT face="courier new,courier"&gt;WEEK&lt;/FONT&gt;".)&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 09:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758008#M239302</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-29T09:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Putting a macro variable inside single quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758028#M239312</link>
      <description>Thank you! I've tried the first solution and that works... will take a look at upgrading to your second solution too!</description>
      <pubDate>Thu, 29 Jul 2021 10:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Putting-a-macro-variable-inside-single-quotations/m-p/758028#M239312</guid>
      <dc:creator>girl_withno_nam</dc:creator>
      <dc:date>2021-07-29T10:28:28Z</dc:date>
    </item>
  </channel>
</rss>

