<?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: Macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835205#M330183</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;One more strange thing&lt;BR /&gt;&lt;BR /&gt;One dataset is with a extra &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Instead of the common &lt;BR /&gt;Monthly.score_New_hkg_&amp;amp;P_YYMMDD. Where &amp;amp;P_YYMMDD. Is a date&lt;BR /&gt;I have this Monthly.score_New_hkg_&amp;amp;&amp;amp;P_YYMMDD.&lt;BR /&gt;I believe actuallu&lt;BR /&gt;&amp;amp;&amp;amp;P_YYMMDD. = &amp;amp;P_YYMMDD.&lt;BR /&gt;&lt;BR /&gt;Right?? What is the purpose of putting two &amp;amp; here?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Purpose? Without seeing an entire program from start to finish and example data I would hesitate to make any guess on a very partial description of a program.&lt;/P&gt;
&lt;P&gt;If the author of the program doesn't document what blocks of code are to accomplish it can be very hard to follow enough logic as to what is going on. Add in the macro language and indirect references of macro variables (i.e. the &amp;amp;&amp;amp; or &amp;amp;&amp;amp;&amp;amp; or &amp;amp;&amp;amp;&amp;amp;&amp;amp; or what may appear) then guesses may be all you get.&lt;/P&gt;
&lt;P&gt;I think &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; may have the right idea: turn on the macro creation information with the MPRINT SYMBOLGEN options to follow the construction of the variables. Then be prepared to spend a lot of time following the original authors code and try to determine the though processes behind what was done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2022 15:40:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-09-26T15:40:19Z</dc:date>
    <item>
      <title>Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/834994#M330065</link>
      <description>I have a variable&lt;BR /&gt;Staging.credit_card_account_h_&amp;amp;&amp;amp;M&amp;amp;month._YYMMDD.&lt;BR /&gt;&lt;BR /&gt;How do I interpret this date with so many &amp;amp; ?</description>
      <pubDate>Sat, 24 Sep 2022 05:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/834994#M330065</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-09-24T05:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/834997#M330066</link>
      <description>Most likely you were careless when posting the code.  I expect there are actually two dots not 1:  &amp;amp;&amp;amp;M&amp;amp;month..  probably you have 13 macro variables:&lt;BR /&gt;M1 through M12&lt;BR /&gt;month (probably a number from 1 to 12, referred to as &amp;amp;month.)&lt;BR /&gt;&lt;BR /&gt;If you need to work with this program, you absolutely must look up and understand how to resolve &amp;amp;&amp;amp;M&amp;amp;month.&lt;BR /&gt;When  &amp;amp;month is 1, it resolves to &amp;amp;M1 which then re-resolves into the value of the macro variable M1&lt;BR /&gt;You need to acquire some familiarity with macro language, or else you will need to ask questions every time.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Sep 2022 07:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/834997#M330066</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-09-24T07:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835000#M330067</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;%let month=1 ;&lt;BR /&gt;%let M1_YYMMDD=X ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;   credit_card_account_h_&amp;amp;&amp;amp;M&amp;amp;month._YYMMDD.&lt;BR /&gt;-&amp;gt;credit_card_account_h_&amp;amp;M1_YYMMDD.&lt;BR /&gt;-&amp;gt;credit_card_account_h_X&lt;BR /&gt;&lt;BR /&gt;But I think Astounding is right .There should be double point :&lt;BR /&gt;"&amp;amp;&amp;amp;M&amp;amp;month.."&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Sep 2022 09:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835000#M330067</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-24T09:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835001#M330068</link>
      <description>&lt;P&gt;Another option is to turn on the macro debugging options with this command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run the code again, and the log will show you what the values of these macro variables are and the SAS code that is created.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Sep 2022 10:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835001#M330068</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-24T10:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835104#M330130</link>
      <description>It reslly us just 1 . at the end and still work&lt;BR /&gt;&lt;BR /&gt;What is significance of this .&lt;BR /&gt;&lt;BR /&gt;What is difference between one or two dots?&lt;BR /&gt;&lt;BR /&gt;Let say instead of &amp;amp;month. I just have &amp;amp;month without . , would it work too? Is it just part of variable name? What about the . After yymmdd at the very end?</description>
      <pubDate>Mon, 26 Sep 2022 05:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835104#M330130</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-09-26T05:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835114#M330133</link>
      <description>One more strange thing&lt;BR /&gt;&lt;BR /&gt;One dataset is with a extra &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Instead of the common &lt;BR /&gt;Monthly.score_New_hkg_&amp;amp;P_YYMMDD. Where &amp;amp;P_YYMMDD. Is a date&lt;BR /&gt;I have this Monthly.score_New_hkg_&amp;amp;&amp;amp;P_YYMMDD.&lt;BR /&gt;I believe actuallu&lt;BR /&gt;&amp;amp;&amp;amp;P_YYMMDD. = &amp;amp;P_YYMMDD.&lt;BR /&gt;&lt;BR /&gt;Right?? What is the purpose of putting two &amp;amp; here?</description>
      <pubDate>Mon, 26 Sep 2022 07:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835114#M330133</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-09-26T07:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835136#M330146</link>
      <description>"&amp;amp;&amp;amp;P_YYMMDD. = &amp;amp;P_YYMMDD.&lt;BR /&gt;Right?? What is the purpose of putting two &amp;amp; here?"&lt;BR /&gt;&lt;BR /&gt;Right. Maybe the coder don't know macro language very well .</description>
      <pubDate>Mon, 26 Sep 2022 11:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835136#M330146</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-26T11:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835182#M330168</link>
      <description>&lt;P&gt;In this string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Staging.credit_card_account_h_&amp;amp;&amp;amp;M&amp;amp;month._YYMMDD&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS needs to know where the name of the macro variable that the &amp;amp; is referencing ends.&amp;nbsp; The period after MONTH shows SAS that the macro variable is named MONTH and not MONTH_YYMMDD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the second pass attempt to resolve the macro variable references the string has now become&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Staging.credit_card_account_h_&amp;amp;M1_YYMMDD&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So this will look for a macro variable named: M1_YYMMDD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have such a macro variable (series of macro variables)?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;M1_YYMMDD
M2_YYMMDD
M3_YYMMDD
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or do you have a series of macro variables named M1, M2, M3 etc?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the later then you need the second period so that the intermediate string is like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Staging.credit_card_account_h_&amp;amp;M1._YYMMDD&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So that SAS will look for M1 macro variable instead of M1_YYMMDD macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 14:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835182#M330168</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-26T14:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835199#M330178</link>
      <description>&lt;P&gt;When you say that the program worked, can I assume you mean that it ran without error and also produced the correct result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can give you the brief explanation.&amp;nbsp; But you will have to find the materials, study them, and know them.&amp;nbsp; There is no way that my knowledge will help you enough to work with these programs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the brief summary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When referring to a macro variable, the . at the end of the name is optional.&amp;nbsp; Both of these refer to the macro variable MONTH:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;month&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes the dot is required to let SAS know what the the name of the macro variable is.&amp;nbsp; In this phrase, SAS won't know:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;month_YYMMDD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS will assume that the name of the macro variable is the whole string so the name of the macro variable is month_YYMMDD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By adding a dot, you can instruct SAS that this is not the case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;month._YYMMDD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dot tells SAS that the name of the macro variable is month, and the characters _YYMMDD are just part of the program but not part of the name of the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must learn this, or else you will be confused by virtually every macro program you encounter.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 15:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835199#M330178</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-09-26T15:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835205#M330183</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;One more strange thing&lt;BR /&gt;&lt;BR /&gt;One dataset is with a extra &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Instead of the common &lt;BR /&gt;Monthly.score_New_hkg_&amp;amp;P_YYMMDD. Where &amp;amp;P_YYMMDD. Is a date&lt;BR /&gt;I have this Monthly.score_New_hkg_&amp;amp;&amp;amp;P_YYMMDD.&lt;BR /&gt;I believe actuallu&lt;BR /&gt;&amp;amp;&amp;amp;P_YYMMDD. = &amp;amp;P_YYMMDD.&lt;BR /&gt;&lt;BR /&gt;Right?? What is the purpose of putting two &amp;amp; here?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Purpose? Without seeing an entire program from start to finish and example data I would hesitate to make any guess on a very partial description of a program.&lt;/P&gt;
&lt;P&gt;If the author of the program doesn't document what blocks of code are to accomplish it can be very hard to follow enough logic as to what is going on. Add in the macro language and indirect references of macro variables (i.e. the &amp;amp;&amp;amp; or &amp;amp;&amp;amp;&amp;amp; or &amp;amp;&amp;amp;&amp;amp;&amp;amp; or what may appear) then guesses may be all you get.&lt;/P&gt;
&lt;P&gt;I think &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; may have the right idea: turn on the macro creation information with the MPRINT SYMBOLGEN options to follow the construction of the variables. Then be prepared to spend a lot of time following the original authors code and try to determine the though processes behind what was done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 15:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835205#M330183</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-26T15:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835799#M330457</link>
      <description>I have another variable&lt;BR /&gt;&lt;BR /&gt;Staging.MY_credit_&amp;amp;yymmdd.&lt;BR /&gt;&lt;BR /&gt;But i couldnt find where is this macro variable being defined, could this be some generic macro variable not needing definition eg %let yymmdd = xxx kind of statement?</description>
      <pubDate>Thu, 29 Sep 2022 10:04:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835799#M330457</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-09-29T10:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835807#M330462</link>
      <description>&lt;P&gt;SAS supports a limited number of so-called "generic" macro variables.&amp;nbsp; But not in this case.&amp;nbsp; The SAS-supplied variable names begin with "sys":&amp;nbsp; &amp;amp;syserr, &amp;amp;sysrc, etc.&amp;nbsp; If you can't find where the macro variable is created, keep looking.&amp;nbsp; It's out there somewhere.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable/m-p/835807#M330462</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-09-29T11:40:00Z</dc:date>
    </item>
  </channel>
</rss>

