Hello,
Is it possible to make a call symputx in a macro function without using a data step as below?
%macro test;
%global Gflag;
Data _null_;
call symputx('Gflag',0);
stop;
run;
%mend test;
%test;
%put &Gflag;
As far as I know, call symputx can only be run in data step.
Perhaps if you could explain what you are doing and why you think you need it outside a data step, we could come up with a simple solution.
As far as I know, call symputx can only be run in data step.
Perhaps if you could explain what you are doing and why you think you need it outside a data step, we could come up with a simple solution.
I just need to do a call symputx in a macro function and I wonder if there is another way to make that call outside of a data step to avoid those extra lines of code.
Data _NULL_;
...
Stop;
run;
just a curiosity!
There are other way to assign values to macro variables, if you are outside a data step. The two that come to mind are PROC SQL and %LET. Wouldn't one of those work for you?
If you need global scope then:
call symput('mvar',0,'g');
The g means set as global. However that being said its really not a good idea to be setting gloabl macro variables inside a macro - scoping, encapsulation etc.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.