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

Hi all,

 

Can someone explain how does recursive macros work. As of my understanding a macro has to be defined before calling it so, how can we call a macro without defining it

 

Regards

Solo

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

During definition of a macro, no other macros are called, only the call statements are compiled. The call happens when the macro is executed, so you can have recursion.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

During definition of a macro, no other macros are called, only the call statements are compiled. The call happens when the macro is executed, so you can have recursion.

solo1947
Calcite | Level 5
Thanks for the quick reply Sir, appreciate it.
Tom
Super User Tom
Super User

It is in the execution that recursion would occur.  You always have to have defined the macro before you can execute it.

 

Remember that the name space for macros is flat.  At any point in time there can only be one definition for macro X.  So there is no nesting of macro definitions (recursive or not).  The nesting occurs when the macros execute.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1049 views
  • 0 likes
  • 3 in conversation