BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BuildsStuff
Calcite | Level 5

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:

 

ValueToStoreMacro_Name
Value ATestContainerA
Value BMacroNameBoy
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 :&macro_name separated by ' '

From test;

Quit;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

A perfect use case for the CALL SYMPUTX() function.

data _null_;
  set test;
  call symputx(Macro_Name,ValueToStore);
run;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

A perfect use case for the CALL SYMPUTX() function.

data _null_;
  set test;
  call symputx(Macro_Name,ValueToStore);
run;
BuildsStuff
Calcite | Level 5
Holy mackerel. There's a function for everything. Love it! Thanks!
PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS Community 🙂

 

Simply use CALL SYMPUTX in a data step instead of PROC SQL logic

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3807 views
  • 5 likes
  • 3 in conversation