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.

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!

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.

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
  • 906 views
  • 0 likes
  • 3 in conversation