Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested Macros

Status
Not open for further replies.

TXSASUser

Programmer
Mar 7, 2006
1
0
0
US
Can someone help me figure out why my code will not run? I have a macro that is using macro variables and I am calling a macro that has parameters, that is also using macro variables. Example:

/* NoTE: I have already run proc sql to assign my macro variables Terr_Code 1 - Terr_Code99 */

%Terr_Count = 5;

%MACRO SummaryOrders;
%do i = 1 %to &Terr_Count;

/* Summarize all Vacant Territories */
PROC Means data = Orders_Coded_&&Terr_Code&i sum;
class Territory_Code Time_Code;
var constant;
output out = Orders_CSum_&Terr_Code;
RUN;
.
.
.
/* Get Control Territories */
%gmatch (data=Orders_CSum_&&Terr_Code&i, group=group, id=Territory_Code, mvars=Number_of_Orders,
wts= 1 , dmaxk=100, dist=1, transf=0, time=timex,
ncontls=5, seedca=234098, seedco=048239,out= Matched_&&Terr_Code&i,
outnmco=matched, print=y);

.
.
.
%End; /* of do */

%MEND SummaryOrders;


%SummaryOrders;

However, while using the PC Editor I can tell that something isn't right because I don't get my grey line after my %MEND statement.

HELP!

Thank you,
Lisa
 
You say it doesn't run, but what does that mean? Did you get error messages? Any messages? This sort of information makes it alot easier to debug.
Also, set up the following options statement before re-running:-
Code:
options mprint mlogic symbolgen;
This should help debugging.

Also, when posting code, if you want it to line up nice like it does in your editor, use the TGML codes as explained under the "Process TGML" link below the message entry box. basically, you start the code with code in square brackets, and end it in /code in square brackets. :)
 
You forgot a percent sign when you set the Terr_count macro var.
Code:
%let Terr_count =5;

That should get you closer to what you expect your code to output.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top