<?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 not running properly when added into another macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Macro-not-running-properly-when-added-into-another-macro/m-p/44162#M11656</link>
    <description>I think you might need a period after &amp;amp;Prog but before the _ in the line that generates the error.  SAS thinks you are trying to use the macrovariable &amp;amp;Prog_ which doesn't exist.  The period tells SAS that the macro token has ended(as do spaces, ampersands, and some others).</description>
    <pubDate>Tue, 05 Apr 2011 14:10:54 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2011-04-05T14:10:54Z</dc:date>
    <item>
      <title>Macro not running properly when added into another macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-not-running-properly-when-added-into-another-macro/m-p/44161#M11655</link>
      <description>I have the current code which calls a macro "WATERFALL_V4" just fine when running my original program.  The code is: %MACRO WATERFALL_v4(Prog); and the call is: %waterfall_v4(Reg) &lt;BR /&gt;
	%if "&amp;amp;Exist" = "YES" %then %do; %waterfall_v4(ALT) %end;&lt;BR /&gt;
&lt;BR /&gt;
The Exist Macro is defined earlier and applies to each observation.  The first dataset this Macro is run on is written as:&lt;BR /&gt;
&lt;BR /&gt;
DATA EligibleLoans_&amp;amp;Prog (KEEP = Mod_Pmt_&amp;amp;Prog Mod_Rte_&amp;amp;Prog Mod_Trm_&amp;amp;Prog Mod_Fore_&amp;amp;Prog new_front_end_ratio_&amp;amp;Prog &lt;BR /&gt;
		RENAME = (Mod_Pmt_&amp;amp;Prog = Calc_Mod_Pmt_&amp;amp;Prog Mod_Rte_&amp;amp;Prog = Calc_Mod_Rte_&amp;amp;Prog Mod_Trm_&amp;amp;Prog = Calc_Mod_Trm_&amp;amp;Prog Mod_Fore_&amp;amp;Prog = Calc_Mod_Fore_&amp;amp;Prog new_front_end_ratio_&amp;amp;prog  = new_dti_&amp;amp;Prog));&lt;BR /&gt;
	SET LoansForNPV_&amp;amp;Prog; RUN;&lt;BR /&gt;
&lt;BR /&gt;
This code ran fine until I tried to place it in another Macro "Quarters", which simply runs the originally dataset after it is segmented into smaller date ranges.  The new code for the first run within the WATERFALL_V4 Macro now reads:&lt;BR /&gt;
&lt;BR /&gt;
DATA EligibleLoans_&amp;amp;Prog_&amp;amp;QTR. (KEEP = Mod_Pmt_&amp;amp;Prog Mod_Rte_&amp;amp;Prog Mod_Trm_&amp;amp;Prog Mod_Fore_&amp;amp;Prog new_front_end_ratio_&amp;amp;Prog &lt;BR /&gt;
		RENAME = (Mod_Pmt_&amp;amp;Prog = Calc_Mod_Pmt_&amp;amp;Prog Mod_Rte_&amp;amp;Prog = Calc_Mod_Rte_&amp;amp;Prog Mod_Trm_&amp;amp;Prog = Calc_Mod_Trm_&amp;amp;Prog Mod_Fore_&amp;amp;Prog = Calc_Mod_Fore_&amp;amp;Prog new_front_end_ratio_&amp;amp;prog  = new_dti_&amp;amp;Prog));&lt;BR /&gt;
	SET LoansForNPV_&amp;amp;Prog_&amp;amp;QTR.; RUN;&lt;BR /&gt;
&lt;BR /&gt;
For some reason that I can't figure out, placing the WATERFALL_V4 macro within the QUARTERS macro now returns this error, indicating that the &amp;amp;prog call is no longer working and is just being read as PROG_ (even though the second line below says "Parameter PROG has value Reg"):&lt;BR /&gt;
&lt;BR /&gt;
MLOGIC(WATERFALL_V4):  Beginning execution.&lt;BR /&gt;
MLOGIC(WATERFALL_V4):  Parameter PROG has value Reg&lt;BR /&gt;
WARNING: Apparent symbolic reference PROG_ not resolved.&lt;BR /&gt;
NOTE: Line generated by the invoked macro "WATERFALL_V4".&lt;BR /&gt;
1           DATA EligibleLoans_&amp;amp;Prog_&amp;amp;QTR.(KEEP =                                -&lt;BR /&gt;
                               22&lt;BR /&gt;
ERROR: Undeclared array referenced: Prog_2010Q4.&lt;BR /&gt;
NOTE: Line generated by the invoked macro "WATERFALL_V4".&lt;BR /&gt;
1                                                              Mod_Pmt_&amp;amp;Prog&lt;BR /&gt;
                                                               ----------&lt;BR /&gt;
                                                               388&lt;BR /&gt;
                                                               76&lt;BR /&gt;
1    ! Mod_Rte_&amp;amp;Prog Mod_Trm_&amp;amp;Prog Mod_Fore_&amp;amp;Prog new_front_end_ratio_&amp;amp;Prog         RENAME =&lt;BR /&gt;
1    ! (Mod_Pmt_&amp;amp;Prog = Calc_Mod_Pmt_&amp;amp;Prog Mod_Rte_&amp;amp;Prog = Calc_Mod_Rte_&amp;amp;Prog&lt;BR /&gt;
NOTE: Line generated by the macro variable "QTR".&lt;BR /&gt;
1      Prog_2010Q4&lt;BR /&gt;
       -----------&lt;BR /&gt;
&lt;BR /&gt;
Please help!  This is driving me crazy!</description>
      <pubDate>Tue, 05 Apr 2011 13:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-not-running-properly-when-added-into-another-macro/m-p/44161#M11655</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-04-05T13:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro not running properly when added into another macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-not-running-properly-when-added-into-another-macro/m-p/44162#M11656</link>
      <description>I think you might need a period after &amp;amp;Prog but before the _ in the line that generates the error.  SAS thinks you are trying to use the macrovariable &amp;amp;Prog_ which doesn't exist.  The period tells SAS that the macro token has ended(as do spaces, ampersands, and some others).</description>
      <pubDate>Tue, 05 Apr 2011 14:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-not-running-properly-when-added-into-another-macro/m-p/44162#M11656</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-04-05T14:10:54Z</dc:date>
    </item>
  </channel>
</rss>

