BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kody_devl
Quartz | Level 8

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

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

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

4 REPLIES 4
Astounding
PROC Star

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.

art297
Opal | Level 21

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

 

Shmuel
Garnet | Level 18

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);

 

Kody_devl
Quartz | Level 8

Shmuel,

 

I tried both options and they both worked.

 

Thanks!

 

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 1190 views
  • 0 likes
  • 4 in conversation