<?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: repeating macro code inside a macro definition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134322#M27281</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%NRSTR hides the macro commands, since my code is multiple lines do I also need to hide the ";"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot see to find a resource that explains these functions clearly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 May 2013 12:38:45 GMT</pubDate>
    <dc:creator>derrick</dc:creator>
    <dc:date>2013-05-17T12:38:45Z</dc:date>
    <item>
      <title>repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134314#M27273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a macro that writes a large number of IML functions.&amp;nbsp; A large part of these functions are the same across all functions.&amp;nbsp; I want to be able to edit that part that all functions share in one place rather than going through each function to make the change.&amp;nbsp; Essentially I would like to create a macro variable that contains these statements (that include macro statement) and then use that variable in each of the macro functions.&amp;nbsp; Is there a macro quoting function that I can use that will allow me to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MACRO write_functions;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET common="%DO;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; some shared code&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START func1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;common&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;some unique code&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;FINISH func1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START func2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;common&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;some unique code&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;FINISH func2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MEND write_functions;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 14:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134314#M27273</guid>
      <dc:creator>derrick</dc:creator>
      <dc:date>2013-05-16T14:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134315#M27274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To put it another way I do not want the contents of &amp;amp;common to resolve when I define it but I want it to resolve when I use it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134315#M27274</guid>
      <dc:creator>derrick</dc:creator>
      <dc:date>2013-05-16T15:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134316#M27275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if &amp;amp;common is a parameter to the macro, you can do what you need to do. but i don't know why you wouldn't make it a separate macro that gets called. this may be useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.analytical-software.de/en/knowledge-library/papers/ioc-for-sas-macro/" title="http://www.analytical-software.de/en/knowledge-library/papers/ioc-for-sas-macro/"&gt;HMS Analytical Software: A Modern Software Design Principle Applied To SAS Macro Programming: The Inversion Of Control Concept&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134316#M27275</guid>
      <dc:creator>aland1</dc:creator>
      <dc:date>2013-05-16T15:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134317#M27276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only 2 macro quoting functions operate at compile time:&amp;nbsp; %str and %nrstr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the others operate at run time.&amp;nbsp; The one you are looking for is probably %bquote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%bquote(&amp;amp;common)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's an outside chance it should be %nrbquote, but that depends on what would be contained in &amp;amp;COMMON.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 16:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134317#M27276</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-05-16T16:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134318#M27277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First try using %NRSTR() to hid the macro commands:&amp;nbsp;&amp;nbsp; %nrstr(%do) .... %nrstr(%to) ... %nrstr(%end)&lt;/P&gt;&lt;P&gt;Did you try just using regular single quotes and then removing them?&lt;/P&gt;&lt;P&gt;%let common = '%do .... ' ;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;%sysfunc(dequote(&amp;amp;common))&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 17:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134318#M27277</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-05-16T17:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134319#M27278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%include might be the way to go&lt;/P&gt;&lt;P&gt;It is resolved at macro run time.&lt;/P&gt;&lt;P&gt;It must be worth trying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;peterC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 21:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134319#M27278</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-05-16T21:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134320#M27279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This doesn't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134320#M27279</guid>
      <dc:creator>derrick</dc:creator>
      <dc:date>2013-05-17T12:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134321#M27280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How would I use the %BQUOTE function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134321#M27280</guid>
      <dc:creator>derrick</dc:creator>
      <dc:date>2013-05-17T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134322#M27281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%NRSTR hides the macro commands, since my code is multiple lines do I also need to hide the ";"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot see to find a resource that explains these functions clearly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134322#M27281</guid>
      <dc:creator>derrick</dc:creator>
      <dc:date>2013-05-17T12:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134323#M27282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dequote doesn't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134323#M27282</guid>
      <dc:creator>derrick</dc:creator>
      <dc:date>2013-05-17T12:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134324#M27283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To use %Bquote, just replace any reference to &amp;amp;COMMON with %BQUOTE(&amp;amp;COMMON),&amp;nbsp; However, taking a closer look at your application, that won't be enough.&amp;nbsp; You added double quotes as part of the value of &amp;amp;COMMON and they are fairly certain to cause a syntax error later when the double quotes get incorporated into your macro code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I change my vote to go with the recommendation from aland1 about making a separate macro.&amp;nbsp; Instead of creating &amp;amp;COMMON, define %COMMON as holding the shared code.&amp;nbsp; That would make it easy to get rid of the double quotes.&lt;/P&gt;&lt;P&gt;%macro COMMON;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; shared code&lt;/P&gt;&lt;P&gt;%mend COMMON;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then refer to %COMMON any place you are currently referring to &amp;amp;COMMON.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134324#M27283</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-05-17T12:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: repeating macro code inside a macro definition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134325#M27284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like defining a macro is the way to go if what you need to have in "common" include macro logic.&lt;/P&gt;&lt;P&gt;Not sure WHY you would need to include MACRO logic for this application.&lt;/P&gt;&lt;P&gt;If the code is just normal SAS statements without macro logic then you can use DEQUOTE() or %INCLUDE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%MACRO write_functions;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%MACRO common;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; some shared code&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%MEND common;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;START func1&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %common&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: inherit;"&gt;&lt;EM&gt;some unique code&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;FINISH func1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;START func2&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %common&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: inherit;"&gt;&lt;EM&gt;some unique code&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;FINISH func2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%MEND write_functions;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 13:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeating-macro-code-inside-a-macro-definition/m-p/134325#M27284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-05-17T13:49:30Z</dc:date>
    </item>
  </channel>
</rss>

