&&abc%eval(&x+1)

Reply
Contributor
Posts: 22

&&abc%eval(&x+1)

Hi All,

 

I get stuck in an easy peasy situation.

 

%let x=2;

%let abc3=got it;

 

Now i want &abc3 but using x+1.So iam using below statement:-

%put &&abc%eval(&x+1);

 

But its not working.

 

Please take me out from this easy peasy situation.

Thank u

Frequent Contributor
Posts: 104

Re: &&abc%eval(&x+1)

Hi,

it's %put %unquote(%quote(&)abc%eval(&x+1));

 

Cheers

________________________

- Cheers -

Contributor
Posts: 22

Re: &&abc%eval(&x+1)

Cheers Thanks
Trusted Advisor
Posts: 1,401

Re: &&abc%eval(&x+1)

Next code works fine, too:

 

%let y = %eval(&x+1);

%put &&abc&y;

Super Contributor
Posts: 377

Re: &&abc%eval(&x+1)

[ Edited ]

Why make this hard on yourself?

 

%let x=2;
%let abc3=got it;
%let y=%eval(&x+1);
%put &&abc&y;

 

I don't have SAS in front of me, but...

 

I think when you do &&abc%eval(&x+1), there is a macro quote character between "abc" & "3".  

 

You could try something like:

 

%put &&abc%unquote(%eval(&x+1)), or perhaps %put %superq(abc%eval(&x+1)) *might* work.  But if I were coding this I would do it as above.  Other approaches look like line noise or obfuscated Perl.

Trusted Advisor
Posts: 1,401

Re: &&abc%eval(&x+1)

using &&abc%... gives warning:

Apparent symbolic reference ABC not resolved

 

the %superq(abc%eval(&x+1)) works fine too.

Super Contributor
Posts: 377

Re: &&abc%eval(&x+1)

Yes I think &&abc%eval(&x+1) yields &&abc<a non-printable macro quoting character>3.

 

And &abc is not defined...&abc3 is.

 

Just do your %eval() first, then use those results as your macro variable suffix.

Super User
Posts: 9,688

Re: &&abc%eval(&x+1)


%let x=2;
%let abc3=got it;
 
%let temp=%eval(&x+1);
%let want=&&abc&temp;



%put &want ;

Ask a Question
Discussion stats
  • 7 replies
  • 379 views
  • 2 likes
  • 5 in conversation