<?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 MACRO %IF DOUBLE semicolon in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615434#M18753</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro output;
%do i=1 %to 10;
data output&amp;amp;i;

%if &amp;amp;i lt 5 %then assignment="&amp;amp;i";; /*？？？？？？*/
run;
%end;
%mend;
%output;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;why I need double semicolon? what condition do I need double semicolon?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jan 2020 19:34:33 GMT</pubDate>
    <dc:creator>shawn123</dc:creator>
    <dc:date>2020-01-06T19:34:33Z</dc:date>
    <item>
      <title>MACRO %IF DOUBLE semicolon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615434#M18753</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro output;
%do i=1 %to 10;
data output&amp;amp;i;

%if &amp;amp;i lt 5 %then assignment="&amp;amp;i";; /*？？？？？？*/
run;
%end;
%mend;
%output;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;why I need double semicolon? what condition do I need double semicolon?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 19:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615434#M18753</guid>
      <dc:creator>shawn123</dc:creator>
      <dc:date>2020-01-06T19:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO %IF DOUBLE semicolon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615436#M18755</link>
      <description>&lt;P&gt;The %IF needs a semicolon and the data step command needs a semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first semicolon ends the %IF statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second semicolon ends the &lt;FONT face="courier new,courier"&gt;assignment="&amp;amp;i"&lt;/FONT&gt; statement in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 19:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615436#M18755</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-06T19:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO %IF DOUBLE semicolon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615437#M18756</link>
      <description>Thank you so much, so If Marco's statement and data step statement are writing together I need to treat them as separate statements?</description>
      <pubDate>Mon, 06 Jan 2020 19:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615437#M18756</guid>
      <dc:creator>shawn123</dc:creator>
      <dc:date>2020-01-06T19:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO %IF DOUBLE semicolon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615444#M18758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295663"&gt;@shawn123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you so much, so If Marco's statement and data step statement are writing together I need to treat them as separate statements?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It would help if I explained briefly how macro statements work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you write code with macro statements, and then run the code, the macro statement is resolved and replaced by non-macro code, which SAS then executes. So the part of your code (with one semicolon)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;i lt 5 %then assignment="&amp;amp;i";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is replaced by &lt;FONT face="courier new,courier"&gt;assignment="1"&lt;/FONT&gt; when &amp;amp;i=1 and this is not a complete SAS data step command, you have to have a semicolon at the end to complete the command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A slightly superior way to write this is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;i lt 5 %then assignment="&amp;amp;i"%str(;);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%str(;)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;resolves to a semicolon and this is the semicolon that ends the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;assignment="1"&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif"&gt;statement; and will only appear when &lt;FONT face="courier new,courier"&gt;&amp;amp;i lt 5&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;So when &amp;amp;i is less than 5, the macro statement resolves to &lt;FONT face="courier new,courier"&gt;assignment="1";&lt;/FONT&gt; (with a semicolon on the end)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;When &amp;amp;i is greater than or equal to 5, the macro statement does not create any SAS code. (If you did it the original way you wrote the program, when &amp;amp;i is greater than or equal to 5, a semicolon is produced ... essentially a blank statement ending with a semicolon, and while in this simple example it makes no difference, there are other cases where it might make a difference)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 19:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615444#M18758</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-06T19:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO %IF DOUBLE semicolon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615541#M18776</link>
      <description>&lt;P&gt;If you reconstruct&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;i lt 5 %then assignment="&amp;amp;i";;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;i lt 5 %then %str(assignment="&amp;amp;i";);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it might be a little more evident.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 04:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/MACRO-IF-DOUBLE-semicolon/m-p/615541#M18776</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-01-07T04:40:05Z</dc:date>
    </item>
  </channel>
</rss>

