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.

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