<?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 in SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183280#M46678</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;%let yy = %sysfunc(intnx(month,%sysfunc(today()),-12),year.);&lt;/P&gt;&lt;P&gt;qtr=qtr(today()-30);&lt;/P&gt;&lt;P&gt;yrqtr=compress('Q'||qtr||&amp;amp;yy)||' Partner details';&lt;/P&gt;&lt;P&gt;call symput('yrqtr',yrqtr);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put &amp;amp;yy &amp;amp;yrqtr;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Sep 2014 20:43:09 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-09-02T20:43:09Z</dc:date>
    <item>
      <title>Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183277#M46675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying the below and it is not working. I need to pass this variable yrqtr to oracle query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;%let yy = %sysfunc(intnx(month,%sysfunc(today()),-12),yymmdd2.);&lt;/P&gt;&lt;P&gt;qtr=qtr(today()-30);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN lang="EN"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;yrqtr=compress('Q'||qtr||yy||'Partner&amp;nbsp; details');&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;call symput('yrqtr',yrqtr);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to make &lt;STRONG&gt;Q32013 Partner Details&lt;/STRONG&gt; and pass it to Oracle query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 19:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183277#M46675</guid>
      <dc:creator>archana</dc:creator>
      <dc:date>2014-09-02T19:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183278#M46676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you have a %let for the first line?&lt;/P&gt;&lt;P&gt;And then in yrqtr you don't refer to it as a macro variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd suggest converting the first part to data step logic rather than macro logic and go from there. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 19:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183278#M46676</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-09-02T19:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183279#M46677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;even by removing %let it is throwing an error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 20:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183279#M46677</guid>
      <dc:creator>archana</dc:creator>
      <dc:date>2014-09-02T20:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183280#M46678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;%let yy = %sysfunc(intnx(month,%sysfunc(today()),-12),year.);&lt;/P&gt;&lt;P&gt;qtr=qtr(today()-30);&lt;/P&gt;&lt;P&gt;yrqtr=compress('Q'||qtr||&amp;amp;yy)||' Partner details';&lt;/P&gt;&lt;P&gt;call symput('yrqtr',yrqtr);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put &amp;amp;yy &amp;amp;yrqtr;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 20:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183280#M46678</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-09-02T20:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183281#M46679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have mixed macro code with data step code.&amp;nbsp; Note there is no reason to put a %LET inside of DATA or PROC step.&amp;nbsp; SAS will evaluate the %LET before it compiles the actual SAS code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this is what you want although I am not sure what the -30 used on finding the quarter means.&amp;nbsp; Is it possible that could mess up the result if you run this in January?&amp;nbsp; Also I have removed the extra space between "Partner" and "details".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is one way to do it with macro logic.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; yy = &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%eval&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(today(),year4) - 1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; qtr = &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(putn(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(today())-30,qtr));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; yrqtr = Q&amp;amp;qtr.&amp;amp;yy Partner details;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; yy=&amp;amp;yy qtr=&amp;amp;qtr yrqtr="&amp;amp;yrqtr" ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the same using a data step.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; yy = year(today())-&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; qtr=qtr(today()-&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;30&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; yrqtr=catx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,cats(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'Q'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,qtr,yy),&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'Partner details'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; yy= qtr= yrqtr= :&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;$quote.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; symputx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'yrqtr'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,yrqtr);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 21:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183281#M46679</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-09-02T21:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183282#M46680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom. Another question. I am trying to pass the above value -&amp;nbsp; yrqtr to an oracle query but not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql exec;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE TABLE test AS select * from connection to oracle&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;select&amp;nbsp; id,id1&amp;nbsp; from table&amp;nbsp; where&amp;nbsp; x = '&amp;amp;yrqtr.');&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 23:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183282#M46680</guid>
      <dc:creator>archana</dc:creator>
      <dc:date>2014-09-02T23:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183283#M46681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; Macro variable references will not resolve in single quotes.&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 01:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183283#M46681</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2014-09-03T01:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183284#M46682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i agree with Cynthia.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason for this is that for the macro variable to resolve, the macro trigger has to recognize macro variable and then has to send the macro variable to macro processor and search the value of macro variable in the global symbol table. however the macro trigger will not recognize the macro variable if it is in single quotes. macro trigger recognizes macro variables in double quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 01:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-variables-in-SAS/m-p/183284#M46682</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2014-09-03T01:59:27Z</dc:date>
    </item>
  </channel>
</rss>

