BookmarkSubscribeRSS Feed
SAS_user_n
Calcite | Level 5
I would like to have call a macro as an input to another macro, and am wondering if there is a good way to do that?

For example, I have %macro1 that transforms a variable and renames it.

%macro1(input1=raw_variable)
==> output is renamed_raw_var

I want to write another %macro2 that takes in "renamed_raw_var" and makes the lags of the variable based on the type of the variable.

%macro2(input2=renamed_raw_var)

Finally, can I do this ? %macro2(input2=%macro1(input1=raw_variable) )

which I tried but did not work. Any suggestion would be greatly appreciated.

Thanks!
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
There is no "lag" type function for macro variables - suggest you track "n" unique macro variable values as "MyMacroVar1" through "MyMacroVar99" or however many you need to run through.

It would be more useful to explain what you are attempting to accomplish for beneficial feedback from the forum subscribers, particularly how you start the process, then each iterative step, working through to the final objective / output.

Scott Barry
SBBWorks, Inc.

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

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