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.

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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