<?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 help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301898#M270419</link>
    <description>&lt;P&gt;If you were to include this statement as part of your program, you would immediately recognize that it won't work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create table P'01Sep2015' as ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's all macro langauge is doing ... substituting text in order to generate the programming statements. &amp;nbsp;While you do require quotes for the date literals, you can't include them as part of the table names. &amp;nbsp;Instead, try calling the macro without quotes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%duo (01Sep2015)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make that work, you would have to add quotes for the date literals:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%macro duo(rptmth);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table P&amp;amp;rptmth as select * from dataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where reportdate GE intnx('month',"&amp;amp;rptmth."d,-12) and reportdate LT intnx('month',"&amp;amp;rptmth."d,1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%mend duo;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use double quotes, not single quotes, around macro variable references. &amp;nbsp;That's a requirement to permit macro language to resolve the values.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Oct 2016 23:06:17 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-10-01T23:06:17Z</dc:date>
    <item>
      <title>MACRO help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301897#M270418</link>
      <description>&lt;P&gt;Hi, I am trying to run a MACRO step to output multiple datasets based on the dates. &amp;nbsp;However, I can't seem to figure out how to mend the dates and create unique table names:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro duo(rptmth);&lt;BR /&gt;proc sql;&lt;BR /&gt;create table P&amp;amp;rptmth as select * from dataset&lt;BR /&gt;where reportdate GE intnx('month',&amp;amp;rptmth.d,-12) and reportdate LT intnx('month',&amp;amp;rptmth.d,1)&lt;BR /&gt;quit;&lt;BR /&gt;%mend duo;&lt;BR /&gt;%duo('01Sep2015');&lt;BR /&gt;%duo('01May2015');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Sat, 01 Oct 2016 22:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301897#M270418</guid>
      <dc:creator>jeffbezos</dc:creator>
      <dc:date>2016-10-01T22:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301898#M270419</link>
      <description>&lt;P&gt;If you were to include this statement as part of your program, you would immediately recognize that it won't work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create table P'01Sep2015' as ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's all macro langauge is doing ... substituting text in order to generate the programming statements. &amp;nbsp;While you do require quotes for the date literals, you can't include them as part of the table names. &amp;nbsp;Instead, try calling the macro without quotes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%duo (01Sep2015)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make that work, you would have to add quotes for the date literals:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%macro duo(rptmth);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table P&amp;amp;rptmth as select * from dataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where reportdate GE intnx('month',"&amp;amp;rptmth."d,-12) and reportdate LT intnx('month',"&amp;amp;rptmth."d,1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%mend duo;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use double quotes, not single quotes, around macro variable references. &amp;nbsp;That's a requirement to permit macro language to resolve the values.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Oct 2016 23:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301898#M270419</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-01T23:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301904#M270420</link>
      <description>Thank you!</description>
      <pubDate>Sun, 02 Oct 2016 02:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-help/m-p/301904#M270420</guid>
      <dc:creator>jeffbezos</dc:creator>
      <dc:date>2016-10-02T02:27:51Z</dc:date>
    </item>
  </channel>
</rss>

