BookmarkSubscribeRSS Feed
nbGuvnig
Calcite | Level 5

Hi,

 

I wish to identify and store the name of a macro variable in another macro variable. I have been able to identify the name of the macro variable by using the %put "&="  command, but haven't been able to assign it to either a variable (data step) or another macro variable.

 

 

%let car = ford;
put &=car;

 

But how do I save the name from the log output to something tangible?

 

BR, Nis

 

3 REPLIES 3
rajeshalwayswel
Pyrite | Level 9
%let car = ford;
%put &car;

Try in this way.

nbGuvnig
Calcite | Level 5

Let me clarify. I do NOT want to evaluate the macro variable. I want the macro variable name.

Astounding
PROC Star

It looks like you have already done what you asked about.  If you want to refer to the name of the macro variable use:

 

&car

 

If you want to refer to the value stored within &FORD, use:

 

&&&car

 

If it's something else entirely, you willl have to give an example of why your code doesn't do what you need.

 

Are you trying to find the name of the macro variable that contains:

 

ford

 

Then examine dictionary.macros.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 795 views
  • 0 likes
  • 3 in conversation