Hi, I have a table that contains a list of values and the macro variable name that I want to store that value in.
Simplified to this example:
| ValueToStore | Macro_Name |
| Value A | TestContainerA |
| Value B | MacroNameBoy |
| Value C | MacroNameTT |
So as a result, I'd like a macro variable named TestContainerA that has the value 'Value A'. MacroNameBoy would have the value 'Value B' and so forth.
I tried several things around this and can't get it working. Any suggestions on another way would be much appreciated:
Proc SQL;
Select macro_name
into :macro_name separated by ' '
From test;
Quit;
Proc SQL;
Select ValueToStore
into :¯o_name separated by ' '
From test;
Quit;
A perfect use case for the CALL SYMPUTX() function.
data _null_;
set test;
call symputx(Macro_Name,ValueToStore);
run;
A perfect use case for the CALL SYMPUTX() function.
data _null_;
set test;
call symputx(Macro_Name,ValueToStore);
run;
Welcome to the SAS Community 🙂
Simply use CALL SYMPUTX in a data step instead of PROC SQL logic
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.
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.
Ready to level-up your skills? Choose your own adventure.