BookmarkSubscribeRSS Feed
JonathanWarrick
Calcite | Level 5
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)
%if "&Exist" = "YES" %then %do; %waterfall_v4(ALT) %end;

The Exist Macro is defined earlier and applies to each observation. The first dataset this Macro is run on is written as:

DATA EligibleLoans_&Prog (KEEP = Mod_Pmt_&Prog Mod_Rte_&Prog Mod_Trm_&Prog Mod_Fore_&Prog new_front_end_ratio_&Prog
RENAME = (Mod_Pmt_&Prog = Calc_Mod_Pmt_&Prog Mod_Rte_&Prog = Calc_Mod_Rte_&Prog Mod_Trm_&Prog = Calc_Mod_Trm_&Prog Mod_Fore_&Prog = Calc_Mod_Fore_&Prog new_front_end_ratio_&prog = new_dti_&Prog));
SET LoansForNPV_&Prog; RUN;

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:

DATA EligibleLoans_&Prog_&QTR. (KEEP = Mod_Pmt_&Prog Mod_Rte_&Prog Mod_Trm_&Prog Mod_Fore_&Prog new_front_end_ratio_&Prog
RENAME = (Mod_Pmt_&Prog = Calc_Mod_Pmt_&Prog Mod_Rte_&Prog = Calc_Mod_Rte_&Prog Mod_Trm_&Prog = Calc_Mod_Trm_&Prog Mod_Fore_&Prog = Calc_Mod_Fore_&Prog new_front_end_ratio_&prog = new_dti_&Prog));
SET LoansForNPV_&Prog_&QTR.; RUN;

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 &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"):

MLOGIC(WATERFALL_V4): Beginning execution.
MLOGIC(WATERFALL_V4): Parameter PROG has value Reg
WARNING: Apparent symbolic reference PROG_ not resolved.
NOTE: Line generated by the invoked macro "WATERFALL_V4".
1 DATA EligibleLoans_&Prog_&QTR.(KEEP = -
22
ERROR: Undeclared array referenced: Prog_2010Q4.
NOTE: Line generated by the invoked macro "WATERFALL_V4".
1 Mod_Pmt_&Prog
----------
388
76
1 ! Mod_Rte_&Prog Mod_Trm_&Prog Mod_Fore_&Prog new_front_end_ratio_&Prog RENAME =
1 ! (Mod_Pmt_&Prog = Calc_Mod_Pmt_&Prog Mod_Rte_&Prog = Calc_Mod_Rte_&Prog
NOTE: Line generated by the macro variable "QTR".
1 Prog_2010Q4
-----------

Please help! This is driving me crazy!
1 REPLY 1
RickM
Fluorite | Level 6
I think you might need a period after &Prog but before the _ in the line that generates the error. SAS thinks you are trying to use the macrovariable &Prog_ which doesn't exist. The period tells SAS that the macro token has ended(as do spaces, ampersands, and some others).

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 747 views
  • 0 likes
  • 2 in conversation