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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

4 REPLIES 4
Tom
Super User Tom
Super User

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.

ballardw
Super User

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.

Tom
Super User Tom
Super User

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)

AhmedAl_Attar
Rhodochrosite | Level 12

@

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 9827 views
  • 7 likes
  • 4 in conversation