DATA Step, Macro, Functions and more

Help needed: Getting macro variable value using variable name built from two scans?

Accepted Solution Solved
Reply
Occasional Contributor tjc
Occasional Contributor
Posts: 7
Accepted Solution

Help needed: Getting macro variable value using variable name built from two scans?

Calling all macro idiot savants!  :-)  Thanks!

* Given the following...;

%let a=x;
%let b=y;
%let xy=12;

* Why does this yield '12'?;
%put &&&a&b;

* And this yields '12'?;
%let z=%scan(&a,1)%scan(&b,1);

%put &&&z;

* But this yields '&xy'? How do I make the ampersands apply to both scan results to yield '12'?;
%put &&&%scan(&a,1)%scan(&b,1);


Accepted Solutions
Solution
‎09-07-2012 10:48 AM
Super User
Posts: 5,080

Re: Help needed: Getting macro variable value using variable name built from two scans?

If the last expression generates &xy, apply %unquote:

%put %unquote(... original expression ...);

View solution in original post


All Replies
Solution
‎09-07-2012 10:48 AM
Super User
Posts: 5,080

Re: Help needed: Getting macro variable value using variable name built from two scans?

If the last expression generates &xy, apply %unquote:

%put %unquote(... original expression ...);

Occasional Contributor tjc
Occasional Contributor
Posts: 7

Re: Help needed: Getting macro variable value using variable name built from two scans?

Dang, your mama named you right, Astounding - worked like a charm!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 173 views
  • 0 likes
  • 2 in conversation