BookmarkSubscribeRSS Feed
Warren
Obsidian | Level 7

Dear Sir/Madam,

                I want to be able to call the function INTRR with a dynamic number of arguments.

 

My program calls INTRR this way: EIRn = INTRR(1, -Orig_Bal %c(n));

 

My macro c is as follows:

macro c(t);

      %do i = 1 %to term;

            , cf&t(&i)

      %end;

%mend c;

 

This gives me the following errors.

ERROR 71-185: The INTRR function call does not have enough arguments.

 

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric

       operand is required. The condition was: term

ERROR: The %TO value of the %DO I loop is invalid.

ERROR: The macro C will stop executing.

 

It worked before when my macro c was as follows:

%macro c(t);

      %do i = 1 %to %maxTerm;

            , cf&t(&i)

      %end;

%mend c;

 

But now, every observation has a different Term, and I cannot assign Term to %maxTerm and use it in the same data step.    How can I resolve this error?

 

Thanks,

Warren

2 REPLIES 2
Warren
Obsidian | Level 7

The following answer is from SAS Technical Support.

 

 

Hello Warren,

 

The following is not valid because you cannot place DATA step variables on a %DO loop.  Term is just seen as text. 

 

%do i = 1 %to term;

 

You will need to do this in multiple steps where you create macro variables in the first step to hold each value of term and then use the macro variables in the second step.

 

Thank You,

Russ Tyndall

SAS Technical Support Analyst

SAS Certified Advanced Programmer for SAS 9

Warren
Obsidian | Level 7

Since my program allows only a maximum of 12 terms, I can simply change my program as follows:

...

%c(n, Term);

...

where the macro c is changed as follows:

 

 

 

%macro c(t, term);

 

select (&term);

 

when (01) EIR&t = INTRR(1,-Orig_Bal,cf&t(1));

when (02) EIR&t = INTRR(1,-Orig_Bal,cf&t(1),cf&t(2));

when (03) EIR&t = INTRR(1,-Orig_Bal,cf&t(1),cf&t(2),cf&t(3));

...

when (12) EIR&t = INTRR(1,-Orig_Bal,cf&t(1),cf&t(2),cf&t(3),cf&t(4),cf&t(5),cf&t(6),

cf&t(7),cf&t(8),cf&t(9),cf&t(10),cf&t(11),cf&t(12));

otherwise put 'ERROR: ' &term=;

end;

 

%mend c;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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