<?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: Macros and Percentage Sign in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735418#M229097</link>
    <description>&lt;P&gt;This calls the macro called &lt;FONT face="courier new,courier"&gt;wednesday&lt;/FONT&gt; defined by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro wednesday();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Apr 2021 04:51:32 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-04-20T04:51:32Z</dc:date>
    <item>
      <title>Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735416#M229096</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I have a macro, inside the macro I have this statement:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;%do i= 2005 %to 2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or percentage sign in this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%if &amp;amp;sysday=Wednesday %then %Wednesday&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you please explain why we put % sign in statements inside a macro. I know that a macro or a variable macro starts with %. Why do the components inside a macro get a percentage sign?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CloudsInSky&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 04:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735416#M229096</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-20T04:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735418#M229097</link>
      <description>&lt;P&gt;This calls the macro called &lt;FONT face="courier new,courier"&gt;wednesday&lt;/FONT&gt; defined by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro wednesday();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 04:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735418#M229097</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-20T04:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735510#M229135</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It's just the way to call a macro inside another&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO a(text=);
   %put %str(N)OTE: &amp;amp;param. &amp;amp;text.!;
%MEND a;

%MACRO b(param=);
   %if %lowcase(&amp;amp;param.) eq hello %then %a(text=Dear);
%MEND b;
%b(param=HelLO);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Apr 2021 12:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735510#M229135</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-04-20T12:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735512#M229136</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I know that a macro or a variable macro starts with %.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;A macro is CALLED by a percent sign and the macro name. Example: %dothis&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A macro starts with %MACRO and ends with %MEND&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A macro variable starts with an ampersand. Example: &amp;amp;flag&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Why do the components inside a macro get a percentage sign?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;To distinguish between text and macro language elements. In your example code, Wednesday is text. %wednesday is a call to a macro.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 12:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735512#M229136</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T12:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735539#M229141</link>
      <description>&lt;P&gt;The macro processor is a text processing language that evaluates the text of your program and changes it before passing the resulting text onto SAS to interpret and run.&amp;nbsp; There are a limited number of predefined macro statements and macro functions and you have the ability with the %MACRO and %MEND statements to define new macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in your code %DO, %TO, %IF and %THEN are macro statements.&amp;nbsp; And %WEDNESDAY is a call to a macro (instead of a native macro processor statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The special characters % and &amp;amp; are triggers to the macro processor to know when it should operate on the text.&amp;nbsp; So the % are significant to the macro processor whether or not the code is inside a macro or not.&amp;nbsp; Some macro code like %LET statements, macro function calls or macro calls can run outside of a user defined macro.&amp;nbsp; You can now even run simple %IF/%THEN/%DO/%END/%ELSE/%DO/%END blocks in "open" code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 13:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735539#M229141</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T13:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735700#M229179</link>
      <description>Thanks for the response.&lt;BR /&gt;Are %lowcase, %if or %then or %put SAS automated macros?&lt;BR /&gt;CloudsIntheSky</description>
      <pubDate>Tue, 20 Apr 2021 17:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735700#M229179</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-20T17:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735708#M229181</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks for the response.&lt;BR /&gt;Are %lowcase, %if or %then or %put SAS automated macros?&lt;BR /&gt;CloudsIntheSky&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Technically, these are macro functions (%lowcase) or macro statements (%if, %then, %put). They are not macros.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735708#M229181</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T18:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735718#M229185</link>
      <description>&lt;P&gt;%IF is a macro statement.&amp;nbsp; %THEN is a macro keyword that is part of the %IF statement.&lt;/P&gt;
&lt;P&gt;%PUT is macro statement.&lt;/P&gt;
&lt;P&gt;%LOWCASE is a SAS supplied autocall macro.&amp;nbsp; You can see where it lives by turning on the MAUTOLOCDISPLAY option.&lt;/P&gt;
&lt;PRE&gt;2354  %put %lowcase(Hello);
MAUTOLOCDISPLAY(LOWCASE):  This macro was compiled from the autocall file C:\Program
                           Files\SASHome\SASFoundation\9.4\core\sasmacro\lowcase.sas
hello
&lt;/PRE&gt;
&lt;P&gt;You can even see the code for the macro by looking at that file:&lt;/P&gt;
&lt;PRE&gt;%macro lowcase(string);
%*********************************************************************;
%*                                                                   *;
%*  MACRO: LOWCASE                                                   *;
%*                                                                   *;
%*  USAGE: 1) %lowcase(argument)                                     *;
%*                                                                   *;
%*  DESCRIPTION:                                                     *;
%*    This macro returns the argument passed to it unchanged         *;
%*    except that all upper-case alphabetic characters are changed   *;
%*    to their lower-case equivalents.                               *;
%*                                                                   *;
%*  E.g.:          %let macvar=%lowcase(SAS Institute Inc.);        %*;
%*  The variable macvar gets the value "sas institute inc."          *;
%*                                                                   *;
%*  NOTES:                                                           *;
%*    Although the argument to the %UPCASE macro function may        *;
%*    contain commas, the argument to %LOWCASE may not, unless       *;
%*    they are quoted.  Because %LOWCASE is a macro, not a function, *;
%*    it interprets a comma as the end of a parameter.               *;
%*                                                                   *;
%*********************************************************************;
%sysfunc(lowcase(%nrbquote(&amp;amp;string)))
%mend;
&lt;/PRE&gt;
&lt;P&gt;Since it is NOT part of the macro language you are free to create a better version of the macro if you want. For example one that does not complain if you have commas in the string you want to lowercase.&lt;/P&gt;
&lt;PRE&gt;2368  %put %lowcase(A,b);
MAUTOLOCDISPLAY(LOWCASE):  This macro was compiled from the autocall file C:\Program
                           Files\SASHome\SASFoundation\9.4\core\sasmacro\lowcase.sas
ERROR: More positional parameters found than defined.

2369  %macro lowcase/parmbuff;
2370  %if %length(%superq(syspbuff)) %then %sysfunc(lowcase&amp;amp;syspbuff);
2371  %mend lowcase;
2372  %put %lowcase(A,b);
a,b

&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/lowcase.sas" target="_self"&gt;https://github.com/sasutils/macros/blob/master/lowcase.sas&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735718#M229185</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T18:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735728#M229188</link>
      <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;
&lt;P&gt;Then we can convert anything, any word, any statement or any function in SAS by placing percentage sign before it.&lt;/P&gt;
&lt;P&gt;Please advise me.&lt;/P&gt;
&lt;P&gt;CloudsIntheSky&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735728#M229188</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-20T18:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735731#M229189</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the response.&lt;/P&gt;
&lt;P&gt;Then we can convert anything, any word, any statement or any function in SAS by placing percentage sign before it.&lt;/P&gt;
&lt;P&gt;Please advise me.&lt;/P&gt;
&lt;P&gt;CloudsIntheSky&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. That is exactly backwards.&amp;nbsp; There is a very specific syntax for the macro language as specified in the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/titlepage.htm" target="_self"&gt;documentation&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735731#M229189</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T19:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735803#M229217</link>
      <description>Can there some functions or some keywords be converted into Macro only?&lt;BR /&gt;Please advise me.&lt;BR /&gt;Regards,&lt;BR /&gt;Clouds in Sky!&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Apr 2021 23:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735803#M229217</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-20T23:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735821#M229226</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Can there some functions or some keywords be converted into Macro only?&lt;BR /&gt;Please advise me.&lt;BR /&gt;Regards,&lt;BR /&gt;Clouds in Sky!&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure I get what you are asking here.&amp;nbsp; If you want to create a macro just use %MACRO and %MEND statement.&amp;nbsp; The actual SAS code that the macro is being used to generate does not change just because a macro is generating it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are talking about the %SYSFUNC() macro function then in general most SAS functions can be called by it.&amp;nbsp; There are some exceptions.&amp;nbsp; The most common thing is that you cannot use it with INPUT() or PUT() functions. Instead you must use one the type specific versions INPUTN(), INPUTC(), PUTN() and PUTC().&amp;nbsp; And it really makes no sense to try to use the CAT...() series of function with it.&amp;nbsp; If you want to concatenate text in macro code just put the text where you want it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsn=&amp;amp;libref..&amp;amp;memname. ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Apr 2021 02:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735821#M229226</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-21T02:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735824#M229228</link>
      <description>Hello team,&lt;BR /&gt;When we want to create a user defined macro, how do we know which components in a macro can take a percentage sign?&lt;BR /&gt;Are there a source for macro keywords and statements that can be used inside a Macro?&lt;BR /&gt;Thanks,&lt;BR /&gt;Blue Sky</description>
      <pubDate>Wed, 21 Apr 2021 04:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/735824#M229228</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-21T04:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/736024#M229293</link>
      <description>&lt;P&gt;Yes, there is.&lt;/P&gt;
&lt;P&gt;By Pressing F1 in your SAS System you should be able to open the SAS help and consult "SAS Products"&amp;gt;"Base SAS"&amp;gt;"SAS 9.x Macro Language Reference"&lt;/P&gt;
&lt;P&gt;Online you'll find the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/titlepage.htm" target="_blank" rel="noopener"&gt;SAS® 9.4 Macro Language: Reference, Fifth Edition&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess the points&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;and&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0a17zv6igdg7jn1e7r6sm0l0gtk.htm" target="_blank" rel="noopener"&gt;Macro Functions&lt;/A&gt;&amp;nbsp;are mainly what you're looking for&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 15:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/736024#M229293</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-04-21T15:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Percentage Sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/736320#M229359</link>
      <description>Hello Oligolas,&lt;BR /&gt;I think your response is what I am looking for.&lt;BR /&gt;Thanks for all your effort.&lt;BR /&gt;I am trying to mark it as a solution, it seems someone has done it prior to me.&lt;BR /&gt;Respectfully,&lt;BR /&gt;Blue Sky!</description>
      <pubDate>Thu, 22 Apr 2021 03:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Percentage-Sign/m-p/736320#M229359</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-22T03:54:57Z</dc:date>
    </item>
  </channel>
</rss>

