DATA Step, Macro, Functions and more

ERROR: More positional parameters found than defined.

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 122
Accepted Solution

ERROR: More positional parameters found than defined.

I am running that the following code and I am getting the error above. The collateral macro seems to compile correctly and the increment variable assumes the correct valued; am I missing smth. Why am I getting this error when trying to run the %main macro?

%main();

%macro main();

  %let increment=25000;

%collateral(&increment);

%mend main();

-Maroulator


Accepted Solutions
Solution
‎10-15-2012 11:04 AM
Super User
Super User
Posts: 7,039

Re: ERROR: More positional parameters found than defined.

And you can specify the parameter names for the positional parameters also in the macro call allowing you to list them in any order you want.

%dummy(var4=value4,var1=value1,var2=value2,var3=value3)

View solution in original post


All Replies
Super User
Super User
Posts: 7,039

Re: ERROR: More positional parameters found than defined.

Posted in reply to maroulator

You probably have some unbalanced quotes or parentheses somewhere and SAS is in a confused state.  Start a new session to get a fresh slate and see if it goes away.

You seem to want to call the macro MAIN before it is defined, but that could just be the way the code got pasted into the posting.

Otherwise there must be something happening in the COLLATERAL macro.  Try just calling it directly and see if you still get the same error.


The most likely problem is that COLLATERAL is defined with named parameters and you are calling it with positional.

For example try this simple test to generate the same problem.

%macro mymac(x=);

%put x="&x";

%mend mymac;

%mymac(100);

If you want to be able to call the macro without specifying the parameter names in the call then do not include the equal signs after the parameter names in the %MACRO statement.

Note that you can still call positional parameters using named syntax, you just can't do it the other way.

Super User
Posts: 11,343

Re: ERROR: More positional parameters found than defined.

And all positional parameters have to come before named.

%macro dummy(var1, var2, var3= , var4=); in definition and

use

%dummy (value1, value2, var3=value3, var4=value4); the order or presence of var3 and var4 are optional as long as they come after var1 and var2.

Solution
‎10-15-2012 11:04 AM
Super User
Super User
Posts: 7,039

Re: ERROR: More positional parameters found than defined.

And you can specify the parameter names for the positional parameters also in the macro call allowing you to list them in any order you want.

%dummy(var4=value4,var1=value1,var2=value2,var3=value3)

Regular Contributor
Posts: 216

Re: ERROR: More positional parameters found than defined.

Posted in reply to maroulator

@

As a side note, check the value you are passing in to you macros (Outer / Inner) either.

If the string value you passing happens to have a comma (,) in it, such as formatted numeric value, or single character value containing a comma.

In order to avoid issues with commas and other special characters that could exists in your data, try to use the following macro functions (%str(), %nrtstr(), %superq()) instead of using the bare &[Var] format.

This is applicable to positional and named macro parameters.

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 6657 views
  • 7 likes
  • 4 in conversation