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

Hi all,

 

I have several macrovariable named:

&mAA
&mAB
&mBA
&mBB
...

Each of them has a string value.

 

Now I create a macro with two arguments 

mymacro ( firststring, secondstring)

I want this macro to be able to modify the current value of one of my macrovariable with the value of secondstring.

Which macrovariable need to be modified? That's the point:

 

The value of the firststring can be "AA","AB","BA,"BB",...

If it is AA I need to modify &mAA

If it is BA I need to modify &mBA

 

Globally I need to do

&m&firststring.. = &secondstring.;

But like this of course, it is not working, and I don't really know how to do it?

 

Do you have an idea?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You'll need to construct a %LET statement to assign a value to a macro variable.  The contents of your macro might end up looking like this:

 

%let m&firststring = &&m&secondstring;

 

Or, it might end up being:

 

%let m&firststring = &secondstring;

 

It's not clear which result you are looking for (probably the second one, based on your sample attempted code), but both of these are somewhere in the ballpark.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

You'll need to construct a %LET statement to assign a value to a macro variable.  The contents of your macro might end up looking like this:

 

%let m&firststring = &&m&secondstring;

 

Or, it might end up being:

 

%let m&firststring = &secondstring;

 

It's not clear which result you are looking for (probably the second one, based on your sample attempted code), but both of these are somewhere in the ballpark.

Planck
Obsidian | Level 7

It's indeed the second one. Sorry if I was not completely clear.

 

Thanks very much for the answer! 🙂

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 2 replies
  • 925 views
  • 1 like
  • 2 in conversation