<?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: Fequently used code in a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203440#M37912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I see what your getting at.&amp;nbsp; Setup the text file so it can just be included, i.e. have the text file:&lt;/P&gt;&lt;P&gt;if a=1 then b=1;&lt;/P&gt;&lt;P&gt;if a=2 then b=2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in the code just do:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=1;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=2;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=3;output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %include "s:\temp\rob\tmp.txt";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good shout that, didn't think of the include in the code itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Apr 2015 15:12:03 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-04-27T15:12:03Z</dc:date>
    <item>
      <title>Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203433#M37905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I use following code in multiple programs. My problem is that if I change any code here then , I need to make same changes in multiple programs to keep it synchronized. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to write a macro, insert the following code in that macro and call that macro in all programs? In that way I just if I need to make updates then I just need to makes changes to one macro and need not worry about keeping all programs synched up.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data A;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;set B;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;if prxmatch("m/XXX/oi",Partner1) &amp;gt; 0 then Principa =&amp;nbsp; 'X';&lt;/P&gt;&lt;P&gt;if prxmatch("m/YYYY/oi",Partner1) &amp;gt; 0 then Principal_SDC= 'Y';&lt;/P&gt;&lt;P&gt;if prxmatch("m/ZZ/oi",Partner1) &amp;gt; 0 then Principal_SDC= 'Z';&lt;/P&gt;&lt;P&gt;if prxmatch.....&lt;/P&gt;&lt;P&gt;if prxmatch..&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 17:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203433#M37905</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-04-24T17:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203434#M37906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you want a macro library, you can create a folde somewhere and then when you launch SAS, you use the SASAUTOS= option to point to this folder. Every SAS macro program in this folder is now available to you for use without you specifically including the macro code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if you have SASAUTOS=(sasautos "\\myserver\mydir\paiges_macros") then every SAS program in that folder is available to your programming. If you have a program in there called donothing.sas which contains %macro dothing; then in any program you write, %donothing is a recognized macro name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, then, if you update this one macro program, every program that calls it gets the updated macro. And of course, you can have as many macros in this folder as you want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 19:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203434#M37906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-04-24T19:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203435#M37907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PaigeMiller,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I followed the step and following is the code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options sasautos=(sasautos "\\C:\Users\Macro"); * this has my macro&amp;nbsp; - PRXmatch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;call execute('%PRXmatch');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is the macro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Prxmatch;&lt;/P&gt;&lt;P&gt;if prxmatch("m/XXX/oi",Partner1) &amp;gt; 0 then Principal= 'X';&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;%mend PRXmatch;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;It gives me this error - Apparent invocation of macro PRXMATCH not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203435#M37907</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-04-27T14:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203436#M37908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The macro is not being defined until after the datastep where it is used is called.&amp;nbsp; Put the %macro before the datastep.&amp;nbsp; However, you could just do away with the macro as that isn't adding anything.&amp;nbsp; Post some test data/required output if you want a more comprehensive answer.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203436#M37908</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-27T14:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203437#M37909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RW9,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My input file has strings on which I want to run PRXmatch command and there are more than 500 Proxmatch commands that I want to run. The 500+ commands are used in multiple programs hence I want to use a macro. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Required output - Extract the 500+ strings into the output file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps. &lt;/P&gt;&lt;P&gt;-----------------------&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;options sasautos=(sasautos "\\C:\Users\Macro"); * this has my macro&amp;nbsp; - PRXmatch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data want;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;call execute('%PRXmatch');&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;this is the macro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%macro Prxmatch;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if prxmatch("m/XXX/oi",Partner1) &amp;gt; 0 then Principal= 'X';&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;..&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%mend PRXmatch;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;-----------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203437#M37909</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-04-27T14:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203438#M37910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, you have a file which is full of commands.&amp;nbsp; The question then is why do you need the macro approach.&amp;nbsp; At the start of your program just do:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length cmd $2000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "xyz.txt" end=eof;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input cmd $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then call execute('data want; set have;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(strip(cmd)||";");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if eof then call execute('run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To add a better example:&lt;/P&gt;&lt;P&gt;I have a file tmp.txt, with two rows: 1) if a=1 then b=1;, 2) if a=2 then b=2;&lt;/P&gt;&lt;P&gt;%macro Get(inds=,outds=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length cmd $200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "s:\temp\rob\tmp.txt" dlm="¬" end=eof;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input cmd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then call execute("data &amp;amp;outds.; set &amp;amp;inds.;");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(cmd);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if eof then call execute("run;");&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend Get;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=1;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=2;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=3;output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%get (inds=have,outds=want);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203438#M37910</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-27T14:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203439#M37911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A few suggestions ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, the call to the macro should be simpler:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %prxmatch&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since your macro contains the statements that should be part of the DATA step, there is no need to add CALL EXECUTE.&amp;nbsp; This won't solve your current problem, but it will solve the one that would have resulted if your program actually located the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, when you say that your folder contains your macro, is it saved in a file named prxmatch.sas? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Third, just as a precaution, get rid of all capital letters.&amp;nbsp; This probably won't matter on a PC but could easily matter on other operating systems.&amp;nbsp; So the name of the file that holds the macro definition should be prxmatch.sas, and the %MACRO and %MEND statements should refer to prxmatch, and the call to the macro should read %prxmatch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203439#M37911</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-04-27T14:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203440#M37912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I see what your getting at.&amp;nbsp; Setup the text file so it can just be included, i.e. have the text file:&lt;/P&gt;&lt;P&gt;if a=1 then b=1;&lt;/P&gt;&lt;P&gt;if a=2 then b=2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in the code just do:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=1;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=2;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=3;output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %include "s:\temp\rob\tmp.txt";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good shout that, didn't think of the include in the code itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203440#M37912</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-27T15:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203441#M37913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;options sasautos=(sasautos "\\C:\Users\Macro");&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it should be&lt;/P&gt;&lt;P&gt;options sasautos=(sasautos "C:\Users\Macro");&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203441#M37913</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-04-27T15:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203442#M37914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While %include will work in some situations, it isn't as flexible or powerful as using SASAUTOS and it has drawbacks. So perhaps in this limited example, %include works as well as SASAUTOS, but I would like to point out some situations where it does not work as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if you have a macro with different arguments&lt;/P&gt;&lt;P&gt;%macro mymacro(arg1=0,arg2=100);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and today you want to call it with arg1=0 and arg2=98, and tomorrow you want to call it with arg1=1 and arg2=14, then the %include approach requires you to edit the file to place these arguments into the code somewhere, and the next time you call it, you can (mistakenly) get these arguments again, unless you remember to edit the macro and change the arguments to the new values that they should take on. And I'm thinking that once you have developed a working macro, you don't want to be constantly editing solely for the purpose of changing the arguments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other drawback to %include is that you have to constantly type the entire line of text including the exact location of the file (which means you have to remember the exact folder location, and type it without typographical errors) as&lt;/P&gt;&lt;P&gt;%include "s:\temp\rob\mymacro.sas";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead of just typing the macro name with a % sign in front of it such as (if said macro was defined with no arguments)&lt;/P&gt;&lt;P&gt;%mymacro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or with arguments&lt;/P&gt;&lt;P&gt;%mymacro(arg1=0,arg2=98)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: in either case, you don't have to remember the location of the macro, and there is no risk of mistyping the location of the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203442#M37914</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-04-27T15:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203443#M37915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;500+ strings as a source. That sounds like the strings are coming from some system and are being stored somewhere.&lt;BR /&gt;You do not like to copy/paste that. But you can make a program that read that all and transform those in usable code parts. &lt;BR /&gt;The idea of creating source-members (RW9) that are included in the other programs could be the fat and most simple approach for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creating source member is putting them writing them as external files like data and including them later as source. Not too difficult to do.&lt;/P&gt;&lt;P&gt;It is using the behavior of SAS as interpreter language and not using the compilation segregation as with many other languages.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 18:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203443#M37915</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-04-27T18:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203444#M37916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two solutions worked perfectly. One with including a text file and other with calling a macro (and yes making all small caps and saving it as .SAS file). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; %include "s:\temp\rob\tmp.txt";&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; %prxmatch&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks you very much !!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 19:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203444#M37916</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-04-27T19:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Fequently used code in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203445#M37917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are just a few reasons to use macros&lt;/P&gt;&lt;P&gt;* conditionals: %if&lt;/P&gt;&lt;P&gt;* loops: %do&lt;/P&gt;&lt;P&gt;* %sysfunc, %sysevalf&lt;/P&gt;&lt;P&gt;* write a function to return a value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example you have posted, I see none of the above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Others have pointed out the %include statement,&lt;/P&gt;&lt;P&gt;which is what I, too, recommend.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The differences, in your situation, where the code is only repetition and has not need of macro statements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* code in the %included program is always compiled in that step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* a macro call generates a search of the sasautos library (set of folders)&lt;/P&gt;&lt;P&gt;and an %include of the file containing the macro&lt;/P&gt;&lt;P&gt;the code is compiled before being used in the step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the way I read your post, you are using this set of prx* statements in multiple programs,&lt;/P&gt;&lt;P&gt;but not more than once in any one program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that is true then there is no benefit to using a macro for this suite of statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I run all my programs in batch,&lt;/P&gt;&lt;P&gt;you may reply that you run several different programs in a session,&lt;/P&gt;&lt;P&gt;in which case the savings gained by the macro being compiled are worthy of consideration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Caveat: just do not change the macro and expect the changes to show up in your next call of the macro.&lt;/P&gt;&lt;P&gt;you are using the compiled version of the macro&lt;/P&gt;&lt;P&gt;you have to recompile the macro, for which there are two ways to get it updated:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. options mrecall;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. %include 'my-macro';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ron Fehd&amp;nbsp; macro maven&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 20:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fequently-used-code-in-a-macro/m-p/203445#M37917</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2015-04-27T20:48:41Z</dc:date>
    </item>
  </channel>
</rss>

