<?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 with % and Macro without % different in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567900#M159759</link>
    <description>&lt;P&gt;I have two codes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Zero (Input=, Output=);
data &amp;amp;Output.;
   set &amp;amp;Input.;
   array change _numeric_;
        do over change;
            if change=. then change=0;
        end;
 run ;
 %mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code-2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Zero (Input=, Output=);
data &amp;amp;Output.;
   set &amp;amp;Input.;
   array change _numeric_;
        %do %over change;
            %if change=. %then change=0;
        %end;
 run ;
 %mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;the only difference is % sign with loop in code-2. I get the same output.&lt;/P&gt;&lt;P&gt;Question is:&lt;/P&gt;&lt;P&gt;1) Why and where % sign is require for macro.&lt;/P&gt;&lt;P&gt;2) if the output is same in both the query why do we need % sign for loop here&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2019 13:18:37 GMT</pubDate>
    <dc:creator>Srigyan</dc:creator>
    <dc:date>2019-06-21T13:18:37Z</dc:date>
    <item>
      <title>macro with % and Macro without % different</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567900#M159759</link>
      <description>&lt;P&gt;I have two codes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Zero (Input=, Output=);
data &amp;amp;Output.;
   set &amp;amp;Input.;
   array change _numeric_;
        do over change;
            if change=. then change=0;
        end;
 run ;
 %mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code-2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Zero (Input=, Output=);
data &amp;amp;Output.;
   set &amp;amp;Input.;
   array change _numeric_;
        %do %over change;
            %if change=. %then change=0;
        %end;
 run ;
 %mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;the only difference is % sign with loop in code-2. I get the same output.&lt;/P&gt;&lt;P&gt;Question is:&lt;/P&gt;&lt;P&gt;1) Why and where % sign is require for macro.&lt;/P&gt;&lt;P&gt;2) if the output is same in both the query why do we need % sign for loop here&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 13:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567900#M159759</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2019-06-21T13:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: macro with % and Macro without % different</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567922#M159766</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first macro definition looks normal.&amp;nbsp; You are using the macro to make the names of the input and output datasets dynamic.&lt;/P&gt;
&lt;P&gt;Your second macro definition makes no sense and will not work.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;What code are you trying to conditionally generate by using %DO and %IF?&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Did you define a macro named OVER somewhere?&amp;nbsp; There isn't any macro statement named %OVER.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;The five character string change will never be equal to period so the code CHANGE=0 will never be generated.&amp;nbsp; Plus if you wanted the macro to generate that as a statement you will need another semi-colon.&amp;nbsp; The one after the zero is currently going to be interpreted as ending the %IF/%THEN statement.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 14:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567922#M159766</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-21T14:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: macro with % and Macro without % different</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567932#M159771</link>
      <description>&lt;P&gt;Arrays are DATA STEP ELEMENTS and can therefore NOT BE USED AS MACRO ELEMENTS!&lt;/P&gt;
&lt;P&gt;It is the same for all data step variables.&lt;/P&gt;
&lt;P&gt;The macro preprocessor is not designed to handle &lt;EM&gt;data&lt;/EM&gt;, it is designed to handle &lt;EM&gt;code&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 14:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567932#M159771</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-21T14:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: macro with % and Macro without % different</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567936#M159773</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200312"&gt;@Srigyan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two codes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code-1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Zero (Input=, Output=);
data &amp;amp;Output.;
   set &amp;amp;Input.;
   array change _numeric_;
        do over change;
            if change=. then change=0;
        end;
 run ;
 %mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code-2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Zero (Input=, Output=);
data &amp;amp;Output.;
   set &amp;amp;Input.;
   array change _numeric_;
        %do %over change;
            %if change=. %then change=0;
        %end;
 run ;
 %mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;the only difference is % sign with loop in code-2. I get the same output.&lt;/P&gt;
&lt;P&gt;Question is:&lt;/P&gt;
&lt;P&gt;1) Why and where % sign is require for macro.&lt;/P&gt;
&lt;P&gt;2) if the output is same in both the query why do we need % sign for loop here&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you actually read the log?&lt;/P&gt;
&lt;PRE&gt;48   %macro Zero (Input=, Output=);
49   data &amp;amp;Output.;
50      set &amp;amp;Input.;
51      array change _numeric_;
52           %do %over change;
ERROR: An unexpected semicolon occurred in the %DO statement.
ERROR: A dummy macro will be compiled.
53               %if change=. %then change=0;
54           %end;
55    run ;
56    %mend;
NOTE: The macro ZERO completed compilation with errors.
      0 instructions 0 bytes.


&lt;/PRE&gt;
&lt;P&gt;And executing the macro:&lt;/P&gt;
&lt;PRE&gt;57   %zero(input=junk, output=work.j)
     -
     180
WARNING: Apparent invocation of macro ZERO not resolved.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that you also&amp;nbsp;reused the same data set names and&amp;nbsp;because the macro with the second definition did not execute that the original output data set was not replaced. So you only think it generated the same output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Moral of the story:&lt;/P&gt;
&lt;P&gt;1) &lt;STRONG&gt;Read the log&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;2) Different code should use different macro names so you know which you are actually testing&lt;/P&gt;
&lt;P&gt;3) Generate different output data set names to actually compare the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 14:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567936#M159773</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-21T14:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: macro with % and Macro without % different</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567944#M159778</link>
      <description>&lt;P&gt;There is a reason for "Read the Log" being second in my list of Maxims. It's THAT important.&lt;/P&gt;
&lt;P&gt;READ THE LOG&lt;/P&gt;
&lt;P&gt;READ THE LOG&lt;/P&gt;
&lt;P&gt;READ THE LOG&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 15:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/567944#M159778</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-21T15:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: macro with % and Macro without % different</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/568122#M159870</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
 if _n_=1 then call missing(weight,height);
run;

proc stdize data=class out=want missing=0 reponly;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Jun 2019 12:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-and-Macro-without-different/m-p/568122#M159870</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-22T12:55:41Z</dc:date>
    </item>
  </channel>
</rss>

