DATA Step, Macro, Functions and more

Macro Variable Parameter Not Recognized

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Macro Variable Parameter Not Recognized

I have a Macro that I want to run if the Parameter that I feed it is user entered to STLD_YN = YES, Otherwise don't run the Marco.

 

Here is how I have it set up:

%Let STLD_YN = Yes;

 /* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */

/* ON SETTLEMENT DAY ONLY*/

/* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */

/* Import Settled Loans */

 

%Settled(&STLD_YN.);

%macro Settled(Settle_Today_Y_N);

 

%let Settle_Today_Y_N = %upcase(&Settle_Today_Y_N);  .....................

 

This works perfectly exept for the first time that I open the Project and run it. (If I re-run it, and every time after, it works)?

 

Here is the Log Error:

85        

86         %Settled(&STLD_YN.);

          _

           180

WARNING: Apparent invocation of macro SETTLED not resolved.

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

87         %macro Settled(Settle_Today_Y_N);

Why is it doing this on the first time only?

 

Many Thanks

 

 

 

 

 

 

 

 

 

 


Accepted Solutions
Solution
‎02-15-2017 11:27 PM
Trusted Advisor
Posts: 1,399

Re: Macro Variable Parameter Not Recognized

You should define the macro before using it and

no need to define macro argument if macro variable is already defined.

 

Either do:

%Let STLD_YN = Yes;
%macro Settled;
   %let Settle_Today_Y_N = %upcase(&STLD_YN); 
.....................
%mend settled;
%Settled(&STLD_YN.);

 Or do:

 

%macro Settled(Settle_Today_Y_N);
       %let Settle_Today_Y_N = %upcase(&Settle_Today_Y_N); 
        .....................
%mendsettled; 
%Settled(YES);

 

View solution in original post


All Replies
Super User
Posts: 5,092

Re: Macro Variable Parameter Not Recognized

Most likely, your Project logic has a piece in the wrong place.  There will be some sort of statement that either defines the macro (think %include here) or that defines the library to search for, to locate macro definitions (think options sasautos=).  That piece of code might appear after the macro is called.  Moving it earlier, before the macro is called, would handle that sort of problem.

PROC Star
Posts: 7,364

Re: Macro Variable Parameter Not Recognized

You haven't really told the forum enough BUT, if you are submitting the commands in the order shown (and your macro is complete i.e., ends with a %mend; statement, then you are calling the macro before it has been compiled.

 

Thus, simply, don't use the 

%Settled(&STLD_YN.);

statement until after you have run the code that defines the macro.

 

HTH,

Art, CEO, AnalystFinder.com

 

Solution
‎02-15-2017 11:27 PM
Trusted Advisor
Posts: 1,399

Re: Macro Variable Parameter Not Recognized

You should define the macro before using it and

no need to define macro argument if macro variable is already defined.

 

Either do:

%Let STLD_YN = Yes;
%macro Settled;
   %let Settle_Today_Y_N = %upcase(&STLD_YN); 
.....................
%mend settled;
%Settled(&STLD_YN.);

 Or do:

 

%macro Settled(Settle_Today_Y_N);
       %let Settle_Today_Y_N = %upcase(&Settle_Today_Y_N); 
        .....................
%mendsettled; 
%Settled(YES);

 

Contributor
Posts: 58

Re: Macro Variable Parameter Not Recognized

Shmuel,

 

I tried both options and they both worked.

 

Thanks!

 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 149 views
  • 0 likes
  • 4 in conversation