<?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 - meaning of % sign in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802575#M315954</link>
    <description>&lt;P&gt;Hi I am not familiar with the kind of macro where there is a % before a lot of words, what do they mean?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro gen_ind(num);
%do i=1 %to &amp;amp;num %by 1;
proc sql;
create table rate_MAC as select
a.*,
.
.
.
Quit;
%end;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Mar 2022 13:15:28 GMT</pubDate>
    <dc:creator>HeatherNewton</dc:creator>
    <dc:date>2022-03-23T13:15:28Z</dc:date>
    <item>
      <title>macro - meaning of % sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802575#M315954</link>
      <description>&lt;P&gt;Hi I am not familiar with the kind of macro where there is a % before a lot of words, what do they mean?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro gen_ind(num);
%do i=1 %to &amp;amp;num %by 1;
proc sql;
create table rate_MAC as select
a.*,
.
.
.
Quit;
%end;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Mar 2022 13:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802575#M315954</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-23T13:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802576#M315955</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I recommend Chapter 1 "Introduction to the Macro Facility" in&amp;nbsp;&lt;A href="https://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_91/base_macro_6997.pdf" target="_blank"&gt;SAS 9.1 Macro Language&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;I Think it's to difficult to explain yout example in two sentences.&lt;/P&gt;
&lt;P&gt;Best, Markus&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 06:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802576#M315955</guid>
      <dc:creator>MarkusWeick</dc:creator>
      <dc:date>2022-03-17T06:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802577#M315956</link>
      <description>&lt;P&gt;These are all&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0b6jxu7c65h63n1inak5lx7fys2.htm" target="_blank" rel="noopener"&gt;Macro Statements&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 06:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802577#M315956</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-17T06:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802587#M315963</link>
      <description>&lt;P&gt;before I saw example where % are only added to %macro and %mend...&lt;/P&gt;
&lt;P&gt;why suddenly they are added to do if&amp;nbsp; then this kind of word?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 08:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802587#M315963</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-17T08:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802591#M315966</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;before I saw example where % are only added to %macro and %mend...&lt;/P&gt;
&lt;P&gt;why suddenly they are added to do if&amp;nbsp; then this kind of word?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because these are macro statements. Please&amp;nbsp;&lt;STRONG&gt;read the documentation&lt;/STRONG&gt;.&lt;BR /&gt;In the link I gave you, go to&amp;nbsp;&lt;U&gt;Understanding and Using the Macro Facility&lt;/U&gt;. This will help you understand what the macro facility does.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 08:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802591#M315966</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-17T08:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802593#M315967</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.8. of the docu:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bruehl_0-1647507344522.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69529iCF6ACA12D00751BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bruehl_0-1647507344522.png" alt="Bruehl_0-1647507344522.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Conditionally creating SAS code gets to the point! It's an advanced concept. For me it helped to take the course&amp;nbsp;&lt;A href="https://support.sas.com/edu/schedules.html?crs=MAC1&amp;amp;ctry=US" target="_blank"&gt;SAS Training in the United States -- SAS® Macro Language 1: Essentials&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 08:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/802593#M315967</guid>
      <dc:creator>MarkusWeick</dc:creator>
      <dc:date>2022-03-17T08:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/803520#M316396</link>
      <description>&lt;P&gt;am I right to say if these if then else loops in within a macro program, it needs % added to if then else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if the if then else condition is not inside a macro program, then no % is required in from of if then else...&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 08:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/803520#M316396</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-23T08:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/803524#M316397</link>
      <description>&lt;P&gt;"&amp;amp;" and "%" are&amp;nbsp;&lt;STRONG&gt;macro triggers&lt;/STRONG&gt; which invoke the macro processor, or tell the macro processor that the following is (&amp;amp;) a macro variable/parameter reference , or (%) a macro statement or macro/macro function call. Everything else is just text to the macro processor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must first understand what the macro processor does. It is a code generator that allows you to create dynamic code. For easier understanding, its elements look a lot like "standard" SAS elements, but they are (in fact) completely different things.&lt;/P&gt;
&lt;P&gt;IF and %IF are &lt;STRONG&gt;completely different things&lt;/STRONG&gt;, although they have similarities, but &lt;STRONG&gt;THEY ARE DIFFERENT&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Same for (e.g.) SUBSTR vs. %SUBSTR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Imagine you want to run a code for datasets that span back before Austria changed to the Euro, but, in case an "old" dataset is encountered, add a conversion to your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;year. lt 2002
%then %do;
amount = amount / 13.7604;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first line compares the &lt;EM&gt;macro variable&lt;/EM&gt; year to a value (mind - NOT a data step variable!!). If that comparison results in TRUE, the following %DO-%END block is executed by the macro processor, so it creates the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;amount = amount / 13.7604;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and feeds it back to the SAS data step compiler. In case you run the analysis for a later year, the statement is not created, and the data step compiler never sees it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year lt 2002
then do;
  amount = amount / 13.7604;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code does not invoke the macro processor, is "seen" by the data step compiler, and uses the &lt;EM&gt;data step variable&lt;/EM&gt; year to make the comparison; the IF is always executed during data step runtime.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 09:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-meaning-of-sign/m-p/803524#M316397</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-23T09:21:03Z</dc:date>
    </item>
  </channel>
</rss>

