<?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: The semicolon after calling a macro, is it better to omit it? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908533#M40641</link>
    <description>&lt;P&gt;It is more likely an issue in the reverse situation.&amp;nbsp; You are calling a macro that has defined parameters, but you don't need to pass any parameter values in the call.&amp;nbsp; In that case SAS will wait until it sees the semi-colon to know that the macro call is done.&lt;/P&gt;
&lt;PRE&gt;7    %macro noparms;
8    * This macro does not use parameters;
9    %mend noparms;
10
11   options mprint;
12   %noparms
MPRINT(NOPARMS):   * This macro does not use parameters;

13   %macro parms(x=1);
14   * This macro does use parameters;
15   %mend parms;
16
17   options mprint;
18   %parms&lt;/PRE&gt;
&lt;P&gt;If you know the macro you are calling is going to generate one or more complete statements then adding a semi-colon does no harm and could fix the problem above when running interactively.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Dec 2023 00:44:50 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-12-18T00:44:50Z</dc:date>
    <item>
      <title>The semicolon after calling a macro, is it better to omit it?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908523#M40638</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The book SAS Certified Professional Guide has this caution:&lt;/P&gt;
&lt;P&gt;A semicolon after a macro call might insert an inappropriate semicolon into the resulting program, leading to errors during compilation or execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After searching the internet, it seems a lot SAS users think the extra semicolon will not be an issue. Anyone has an example of when the semicolon after a macro call will be an issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2023 21:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908523#M40638</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2023-12-17T21:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: The semicolon after calling a macro, is it better to omit it?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908525#M40639</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253026"&gt;@cosmid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The book SAS Certified Professional Guide has this caution:&lt;/P&gt;
&lt;P&gt;A semicolon after a macro call might insert an inappropriate semicolon into the resulting program, leading to errors during compilation or execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Agree completely, there are situations where a semi-colon after calling a macro is not a problem, and situations where it is a problem. Best to leave it off, and then you never run into a problem with an extra semi-colon in your code.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2023 22:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908525#M40639</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-12-17T22:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: The semicolon after calling a macro, is it better to omit it?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908526#M40640</link>
      <description>&lt;P&gt;I've got into error conditions when calling a macro without parameters not using a semicolon.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
  &amp;lt;some code&amp;gt;
%mend;
%test&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is why I always define and call macros like below even if they don't have a parameter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test();
  &amp;lt;some code&amp;gt;
%mend;
%test()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I personally prefer to end macros with a semicolon even though it's not necessary - except if it's a function style macro used in the middle of some expression where a semicolon of course would terminate the SAS expression in the wrong place. ...but then I avoid such function style macros as far as I can.&lt;/P&gt;
&lt;P&gt;Can't think of any other case where this unnecessary semicolon would create issues.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2023 22:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908526#M40640</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-17T22:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: The semicolon after calling a macro, is it better to omit it?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908533#M40641</link>
      <description>&lt;P&gt;It is more likely an issue in the reverse situation.&amp;nbsp; You are calling a macro that has defined parameters, but you don't need to pass any parameter values in the call.&amp;nbsp; In that case SAS will wait until it sees the semi-colon to know that the macro call is done.&lt;/P&gt;
&lt;PRE&gt;7    %macro noparms;
8    * This macro does not use parameters;
9    %mend noparms;
10
11   options mprint;
12   %noparms
MPRINT(NOPARMS):   * This macro does not use parameters;

13   %macro parms(x=1);
14   * This macro does use parameters;
15   %mend parms;
16
17   options mprint;
18   %parms&lt;/PRE&gt;
&lt;P&gt;If you know the macro you are calling is going to generate one or more complete statements then adding a semi-colon does no harm and could fix the problem above when running interactively.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 00:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/The-semicolon-after-calling-a-macro-is-it-better-to-omit-it/m-p/908533#M40641</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-18T00:44:50Z</dc:date>
    </item>
  </channel>
</rss>

