Help using Base SAS procedures

macro skill problem

Reply
Regular Contributor
Posts: 222

macro skill problem

Hello everyone,

Why if I use (5 or 6 )to replace (3 and 4) will NOT get 'a' in the SAS log?

Thanks!

Mike

/*1.*/%let g=2;
/*2.*/%let cc3=a;
/*3.*/%let k= %eval(&g+1);
/*4. */%put &&cc&k;


/*5.*/%put &&cc%eval(&g+1);
/*6.*/%put &cc%eval(&g+1);

Respected Advisor
Posts: 3,156

Re: macro skill problem

Posted in reply to Mike_Davis

cause '&' resolves before %eval computation.

&&cc%eval(&g+1) -> &cc%eval(2+1) -> 'warning: cc not resolved' ->&cc3

Haikuo

Trusted Advisor
Posts: 1,301

Re: macro skill problem

Posted in reply to Mike_Davis

The %eval is just going to concatenated to the resolution of the macro variable &&cc or &cc.  Compound macro variable resolution is not available in that syntax.

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071915.htm

%let g=2;

%let cc3=a;

%put %unquote(%nrstr(&cc)%eval(&g + 1));

Regular Contributor
Posts: 222

Re: macro skill problem

awesome!

Thank you!

Frequent Contributor
Posts: 127

Re: macro skill problem

Posted in reply to Mike_Davis

Hi Mike,

You might also use the following alternative:


     %put %superq(cc%eval(&g+1));

Regards,

Florent

Regular Contributor
Posts: 222

Re: macro skill problem


That is fantastic!

Thanks!

Mike

Ask a Question
Discussion stats
  • 5 replies
  • 237 views
  • 6 likes
  • 4 in conversation