BookmarkSubscribeRSS Feed
linaad
Calcite | Level 5

i used macro to define a new variable "impulse" so that i can conduct impulse function later on.  however when i ran the following code , the system showed "

ERROR: Invalid macro name (. It should be a valid SAS identifier no longer than 32 characters.
ERROR: A dummy macro will be compiled." why ?

code:

 

%macro impulse(nnctry,nnperiod);
%do k = 1 %to &nnctry;
%let ctry = P[&k,1:&nnctry];
%do n = 2 %to &nnperiod;
%let m1 = %eval(&nnctry*(&n-1)+1);
%let m2 = %eval(&nnctry*(&n));
ctry&k = &ctry//P[&k,&m1:&m2];
%let ctry = ctry&k;
%end;

%mend;

 

4 REPLIES 4
Kurt_Bremser
Super User

@linaad wrote:

i used macro to define a new variable "impulse" so that i can conduct impulse function later on.  however when i ran the following code , the system showed "

ERROR: Invalid macro name (. It should be a valid SAS identifier no longer than 32 characters.
ERROR: A dummy macro will be compiled." why ?

code:

 

%macro impulse(nnctry,nnperiod);
%do k = 1 %to &nnctry;
%let ctry = P[&k,1:&nnctry];
%do n = 2 %to &nnperiod;
%let m1 = %eval(&nnctry*(&n-1)+1);
%let m2 = %eval(&nnctry*(&n));
ctry&k = &ctry//P[&k,&m1:&m2];
%let ctry = ctry&k;
%end;

%mend;

 


Macros are NOT for handling data (which also means the creation of data step or dataset variables), but for creating dynamic (program) text. So it seems to me that the macro is NOT the tool of choice here.

What are you trying to achieve here (in the context of your Base SAS code)?

If you need dynamic SAS code, start with working SAS code for a single instance, and then expand from that.

 

For further help, post the log including the macro definition and the whole step where your macro is used. Use the {i} button for posting logs.

linaad
Calcite | Level 5

thanx , i have sorted out the problem.

ballardw
Super User

@linaad wrote:

thanx , i have sorted out the problem.


Can you describe what sorted out the problem? It might help someone searching the forum that finds this to be similar to their question in reaching a solution.

ballardw
Super User

Without log created with the option Mprint turned on it is hard to point to specific point.

 

I have to say that this line of code looks problematic:

ctry&k = &ctry//P[&k,&m1:&m2];

What is this actually supposed to do? If this supposed to part of a data step somewhere the // will generate and error. Plus the bit

P[&k,&m1:&m2] is almost certain to cause an array reference error.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1537 views
  • 0 likes
  • 3 in conversation