<?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 Write Macro at end of Code in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317819#M21377</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it possible in SAS to call a macro and write the macro at the end of the programm?&lt;/P&gt;&lt;P&gt;It works, but i would need to run the programm twice. Are there any other ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%mymacro;


proc sql;

select id_discriminator, count(*)

   from work.macro_table

   group by 1;

quit;


%macro mymacro;

proc sql;

create table work.macro_table as

   select id_discriminator

      from data_have;

quit;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Dec 2016 07:58:55 GMT</pubDate>
    <dc:creator>Mart_Schm</dc:creator>
    <dc:date>2016-12-09T07:58:55Z</dc:date>
    <item>
      <title>Write Macro at end of Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317819#M21377</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it possible in SAS to call a macro and write the macro at the end of the programm?&lt;/P&gt;&lt;P&gt;It works, but i would need to run the programm twice. Are there any other ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%mymacro;


proc sql;

select id_discriminator, count(*)

   from work.macro_table

   group by 1;

quit;


%macro mymacro;

proc sql;

create table work.macro_table as

   select id_discriminator

      from data_have;

quit;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 07:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317819#M21377</guid>
      <dc:creator>Mart_Schm</dc:creator>
      <dc:date>2016-12-09T07:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro at end of Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317824#M21378</link>
      <description>&lt;P&gt;A macro has to be defined before it is called. One option is to put your macro into an AUTOCALL macro library from where it is defined automatically when referenced in your program.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 08:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317824#M21378</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-12-09T08:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro at end of Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317837#M21379</link>
      <description>&lt;P&gt;You can put a macro definition anywhere, so long as it appears *before* the call to that macro. &amp;nbsp;Autocall library is one option. &amp;nbsp;Saving to a text file and using %include at the top of your program is another. &amp;nbsp;What exactly are you attemting to do? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 09:43:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317837#M21379</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-12-09T09:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro at end of Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317838#M21380</link>
      <description>&lt;P&gt;my goal was (is) to make the code more readable.&lt;BR /&gt;I read now about autocall librarys and i think this works fine for me.&lt;/P&gt;&lt;P&gt;Thanks for your answer&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 09:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317838#M21380</guid>
      <dc:creator>Mart_Schm</dc:creator>
      <dc:date>2016-12-09T09:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro at end of Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317843#M21381</link>
      <description>&lt;P&gt;Easiest ways to make code more readable&amp;nbsp;other than using good coding practices (such as consistent casing, indentation, finishing blocks etc.) would be to reduce the use of macro language. &amp;nbsp;Macro language is an additional tool which is only there to remove the need to repeat code, however it is vastly abused. &amp;nbsp;There should almost never be a time where you resort to macro as you can't do something in Base SAS. &amp;nbsp;Also, don't wrap self explanatory code in macros, too often I see:&lt;/P&gt;
&lt;P&gt;%macro dosomething ();&lt;/P&gt;
&lt;P&gt;proc sort data=abc;data abc; set x=1;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is a total waste of space, and obfuscates it totally to no additional value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason I mention this is because, from a readability sense, so long as a macro has followed SDLC processes, you will have a function design specification, along with probably a user guide. &amp;nbsp;So seeing the code should not really be necessary because of the good documentation. &amp;nbsp;However in 99% of the macro libraries I come across there is zero documentation, poor programming standards, and plenty of obfuscation.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 10:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Write-Macro-at-end-of-Code/m-p/317843#M21381</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-12-09T10:13:45Z</dc:date>
    </item>
  </channel>
</rss>

